2016-04-19 8 views
0

После того, как элементы svg размещены/нарисованы в Indesign, я хочу изменить стиль от некоторые или все элементы. В моем примере я стилю textFrames, пока они нарисованы. Мой пример работает.Basil.js и ExtendScript в Indesign/Как я могу стилить текстовые рамки?

Но как я могу изменить стиль после textFrames размещены?

Я хочу использовать перекос угол (применяется к TextFrame) и rotationAngle (смотрите в моем примере -> forLoop)

Я попытался следующие: r.textFrames.shearAngle=20; и doc.textFrames.add({shearAngle:20}); ... но и не Работа.

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

    // this script shows how to load data into 
    // basil for further usage. 
    // The document you are working with needs to be saved at least once. 
    // The data needs to be in a folder next to that document 
    // The folder needs to be named "data" 
    // take a look into the output of the JS console of the ESTK 
    function draw() { 
     var doc = b.doc(); 
     b.clear(doc); // clear the doc 
     b.units(b.MM); // use MM 
     var yTextFrame = 195; 
     // get the scripts name// get its containing folder// get the name of the script without the extension // add the .indd to the extension 
     var fname = File($.fileName).parent.fsName + '/' + ($.fileName.split('/')[$.fileName.split('/').length - 1]).split('.')[0] + '.indd'; 
     // and save it 
     doc.save(fname, false, 'basil', true); //save the file next to the script 

     // code goes here ----------- 
     var filecontent = b.loadString("data.json"); // load the text file 
     b.println(filecontent.constructor.name); // take a look at what kind of content we have 
     var json = b.JSON.decode(filecontent); // transform it to JSON 
     b.println(json.constructor.name); // take a look again what json is 
     b.println(json.description); // print something from the file 
     // loop all the entries 
     for (var i = 0; i < 5; i++) { 
     b.println(json.laundry_care_instructions[i].instruction); // take a look at the entry 
     b.println(json.laundry_care_instructions[i].instruction.length); // how many characters does the entry have 
     var r =b.text(json.laundry_care_instructions[i].instruction, 10 + 7 * i, yTextFrame, b.width - 20, 7).properties={rotationAngle:90, shearAngle:20};// create a text box with the entry // // The skewing angle applied to the TextFrame 
     } 
     // end of your code --------- 

    } 
    b.go(); 

ответ

1

Вы почти получили его. В вашем коде переменная r уже является объектом textFrame.

Так оно и должно быть:

r.shearAngle = 20; 

Увидимся завтра в классе ;-)

Edit1:

Как сказано в комментариях. Код

var r = b.text("txt",x,y,width, height).properties = {something:10}; 

возвращает объект properties. Не TextFrame. Удалите часть .properties и Benedikts, и мой путь должен работать.

Edit2:

Benedikts способ не работает. Я получаю следующую ошибку.

Error: Object does not support the property or method 'shearAngle' 

@Benedikt: shearAngle не свойство текста. Это для pageItems, таких как TextFrame, Rectangle, Oval и т. Д. Есть ли способ в Basil.js установить свойства, подобные этим? И как это происходит с вложенными свойствами? Для этого я настрою new question.

+0

Эй, Фабиан, ваша версия звучит логично. но это не сработает. странное ^^ вот мое решение: doc.textFrames.item (0) .shearAngle = 20; – LolaRuns

+0

Обычно стенограмма 'b.typo (r," shearAngle ", 20)' тоже должна делать трюк. –

+0

Возможно, вызов .properties в конце создает проблему. Попробуйте вывести r на консоль. b.println (r.constructor.name); после вашего var r = ... Он должен дать вам «TextFrame», если вы получите «объект», это проблема. – fabianmoronzirfas

 Смежные вопросы

  • Нет связанных вопросов^_^