Copy link to clipboard
Copied
Hi, I use Illustrator to create worksheets for my students in preschool. I'm searching for tool or scrypt that allow me random mix postition of objects (letters, number). I have grid under those objects, and I wish that after mixing objects they stay in the middle of grid. Am I only dreaming that something like that exsist? Help ❤️
2 Correct answers
using the above method I've outlined. here's a script to randomise the text thats currently in the frame.
if(app.activeDocument.selection.length==1 && app.activeDocument.selection[0].typename=="TextFrame"){
var StartContents = app.activeDocument.selection[0].contents
var ShuffledContents = shuffleArray(StartContents)
app.activeDocument.selection[0].contents = ShuffledContents
} else {
alert("Whoops!\nPlease select a text frame and try again.")
}
function shuffleArray(Arr) {
...
// select text frames
var doc = app.activeDocument;
var contents = [];
for (var i = 0; i < doc.selection.length; i++) {
contents.push(doc.selection[i].contents);
}
for (var i = 0; i < doc.selection.length; i++) {
var index = Math.floor(Math.random() * contents.length);
doc.selection[i].contents = contents[index];
contents.splice(index, 1);
}
Explore related tutorials & articles
Copy link to clipboard
Copied
While I am certain something could be created via scripting, if I'm understanding your ask correctly a similar effect can be achieved using native tools like area type options and text margins.
- Create your underlying grid
- Create a large Area Type Frame to cover the grid
- Edit the Area type options so that the Rows/Columns match the grid
- then get the Margins to push in and left to align
Here is a 50mm x 50mm grid that is ultimately a single text frame with a string of letters/numbers that flow from 1 box to the next. you could simply retype whatever you wish or copy/paste a string into the text frame and each character would flow into the next box in line
Copy link to clipboard
Copied
Thank you for replay. Now it's easier to prepare grid with numbers/letters. The thing is I wish I could change/mix it somehow, so they randomly change their places, mix in those 5 rows and 5 columns. Sorry, I don't know how to explain it properly O_O I have 'randomus' script, but it only change properities not places ;(
Copy link to clipboard
Copied
using the above method I've outlined. here's a script to randomise the text thats currently in the frame.
if(app.activeDocument.selection.length==1 && app.activeDocument.selection[0].typename=="TextFrame"){
var StartContents = app.activeDocument.selection[0].contents
var ShuffledContents = shuffleArray(StartContents)
app.activeDocument.selection[0].contents = ShuffledContents
} else {
alert("Whoops!\nPlease select a text frame and try again.")
}
function shuffleArray(Arr) {
if(typeof Arr=="string")Arr = Arr.split("")
for (var i = Arr.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = Arr[i];
Arr[i] = Arr[j];
Arr[j] = temp;
}
return Arr.join("")
}
it will only work on a single text frame
it will take the contents of the text frame, in this case a string of numbers or letters, and randomise them amongst themselves and then set that text frame's contents to the new randomised string.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
// select text frames
var doc = app.activeDocument;
var contents = [];
for (var i = 0; i < doc.selection.length; i++) {
contents.push(doc.selection[i].contents);
}
for (var i = 0; i < doc.selection.length; i++) {
var index = Math.floor(Math.random() * contents.length);
doc.selection[i].contents = contents[index];
contents.splice(index, 1);
}
Copy link to clipboard
Copied
Thank you! I'll check them ! It took me so much precious time to prepare something for my kiddos.Tons of 💕

