Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
2

Random letters and numbers mixing position in grid

Community Beginner ,
Feb 28, 2024 Feb 28, 2024

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 ❤️

TOPICS
How-to , Scripting

Views

519
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Participant , Feb 28, 2024 Feb 28, 2024

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) {
    
...

Votes

Translate
Guide , Feb 28, 2024 Feb 28, 2024

 

femkeblanco_0-1709143923784.pngexpand imagefemkeblanco_1-1709143968820.pngexpand imagefemkeblanco_2-1709143999213.pngexpand image

// 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);
}

 

Votes

Translate
Adobe
Participant ,
Feb 28, 2024 Feb 28, 2024

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.

  1. Create your underlying grid
  2. Create a large Area Type Frame to cover the grid
  3. Edit the Area type options so that the Rows/Columns match the grid
  4. 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

Screenshot 2024-02-28 at 12.00.55 PM.pngexpand image

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 28, 2024 Feb 28, 2024

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 ;( 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 28, 2024 Feb 28, 2024

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2024 Feb 28, 2024

Copy link to clipboard

Copied

There are scripts. One is provided by sky-chaser-high.

 

Shuffle Objects

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 28, 2024 Feb 28, 2024

Copy link to clipboard

Copied

 

femkeblanco_0-1709143923784.pngexpand imagefemkeblanco_1-1709143968820.pngexpand imagefemkeblanco_2-1709143999213.pngexpand image

// 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);
}

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 28, 2024 Feb 28, 2024

Copy link to clipboard

Copied

LATEST

Thank you! I'll check them ! It took me so much precious time to prepare something for my kiddos.Tons of 💕

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines