2016-04-19 9 views
0

Nachdem die SVG-Elemente in Indesign platziert/gezeichnet wurden, möchte ich den Stil ändern von einige oder alle Elemente. In meinem Beispiel style ich die textFrames während sie gezeichnet werden. Mein Beispiel funktioniert.Basil.js und ExtendScript in Indesign/Wie kann ich textFrames stylen?

Aber wie kann ich den Stil ändern nach die textFrames platziert sind?

Ich will die Verdrehungswinkel verwenden (auf die Textframe angewandt wird) und die Rotation (in meinem Beispiel sehen -> forloop)

habe ich versucht, die folgend: r.textFrames.shearAngle=20; und doc.textFrames.add({shearAngle:20}); ... aber beide nicht Arbeit.

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

Antwort

1

Sie haben es fast geschafft. In Ihrem Code ist die Variable r bereits ein textFrame-Objekt.

So sollte es sein:

r.shearAngle = 20; 

Sie morgen in der Klasse sehen ;-)

Edit1:

Wie gesagt in den Kommentaren. Der Code

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

gibt die properties Objekt. Nicht der TextFrame. Entferne den .properties Teil und Benedikts und mein Weg sollte funktionieren.

Edit2:

Benedikts Art und Weise funktioniert nicht. Ich erhalte den folgenden Fehler.

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

@Benedikt: shearAngle ist keine Texteigenschaft. Es ist für pageItems wie TextFrame, Rectangle, Oval und so weiter. Gibt es in Basil.js eine Möglichkeit, Eigenschaften wie diese festzulegen? Und wie ist es mit verschachtelten Eigenschaften? Ich werde dafür eine new question einrichten.

+0

Hey Fabian, deine Version klingt logisch. aber es funktioniert nicht. seltsam ^^ hier sind meine Lösung: doc.textFrames.item (0) .shearAngle = 20; – LolaRuns

+0

Normalerweise sollte auch die Kurzschrift 'b.typo (r," shearAngle ", 20) funktionieren. –

+0

Möglicherweise verursacht der Aufruf von .properties am Ende das Problem. Versuche r an der Konsole auszugeben. b.println (r.constructor.name); nach deiner var r = ... Es sollte dir "TextFrame" geben, wenn du ein "Objekt" bekommst, ist die Eigenschaft das Problem. – fabianmoronzirfas

Verwandte Themen