0

I would like to split a title from a textBox in multiples textBox, one for each word of the title.

I'm using Basil.js for scripting in Indesign, I managed to create a script that detects which textBox is selected, counting the number of words and creating a new textBox for each word.

My problem is that the script don't seems to be able to write the words in the textBoxes, at every run the program write [Object Word] instead of the desired word in the textBoxes.

I don't know how to tell it to pick the right words to put in the text boxes.

#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";

function draw() {

    var selItems = b.selection();
    
    var textFrame1 = selItems;
    
     var words1 = b.words(textFrame1);
    
    for(var i = 0; i < words1.length; i++){ 

      var w1 = words1[i+1]; 

      var x = b.random(b.width)
      var y = b.random(b.height)
      
      b.text(w1,x,y,100,100)
        
    }
}

b.go();

Before running the script:
enter image description here

After the script run:
enter image description here

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

0 Answers0