Skip navigation
Currently Being Moderated

why can not create a new line ?

Mar 30, 2012 9:28 PM

hi guys,

i run the below code

script = '';

script += "var docRef = app.documents.add(800,600, 300);\n";

script += "var myLayer8 = docRef.artLayers.add();\n";

script += "myLayer8.kind = LayerKind.TEXT;\n";

script += "myLayer8.textItem.font='FolioBT-BoldCondensed';\n";

script += "myLayer8.textItem.size='15.1848010253906 pt';\n";

script += "var textColor8 = new SolidColor;\n";

script += "textColor8.rgb.hexValue = '000000';\n";

script += "myLayer8.textItem.color = textColor8;\n";

script += "myLayer8.textItem.contents = 'fsafafa \\r fasda';\n";

 

var bt = new BridgeTalk();

bt.target = "photoshop";

bt.body = script;

bt.send();

 

the result is this:

 

QQ截图2jpg.jpg

 

but, i want to like this , how to do it and does anybody can help me? Thanks!

QQ截图3.jpg

 
Replies
  • Currently Being Moderated
    Mar 31, 2012 12:17 AM   in reply to michael.shen

    Could you try 

    script += "myLayer8.textItem.contents = 'fsafafa \r fasda';\n";

    ?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 12:38 AM   in reply to michael.shen

    Sorry, I had posted hastily and so far can’t get it to work either.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 1:32 AM   in reply to michael.shen

    Please try this...

     

     

    function script(){
    var docRef = app.documents.add(800,600, 300);
    var myLayer8 = docRef.artLayers.add();
    myLayer8.kind = LayerKind.TEXT;
    myLayer8.textItem.font='FolioBT-BoldCondensed';
    myLayer8.textItem.size='15.1848010253906 pt';
    var textColor8 = new SolidColor;
    textColor8.rgb.hexValue = '000000';
    myLayer8.textItem.color = textColor8;
    myLayer8.textItem.contents ="fsafafa" + String.fromCharCode(13) + "rfasda";
    }
    var bt = new BridgeTalk();
    bt.target = "photoshop";
    bt.body = "var main = " + script.toSource() + "; main();";
    bt.send(4);
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 5:03 AM   in reply to michael.shen

    I don't think this forum isworking as it should as it doesn't show your last request?

     

    Here is an example of creating several text layers....

     

     

    function script(){
        
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var docRef = app.documents.add(800,600, 300);
     
    
    addTextayer(10,50,"abc","def");
    addTextayer(100,250,"ghi","jkl");
    addTextayer(200,450,"mno","pqr");
     
    app.preferences.rulerUnits = startRulerUnits;
    function addTextayer(x,y,line1,line2){
    var myTextLayer = activeDocument.artLayers.add();
    myTextLayer.kind = LayerKind.TEXT;
    myTextLayer.textItem.font='FolioBT-BoldCondensed';
    myTextLayer.textItem.size='15.1848010253906 pt';
    var myTextColour = new SolidColor;
    myTextColour.rgb.hexValue = '000000';
    myTextLayer.textItem.color = myTextColour;
    myTextLayer.textItem.contents =line1 + String.fromCharCode(13) + line2;
    myTextLayer.textItem.position = Array(x, y); 
        }
    }
    var bt = new BridgeTalk();
    bt.target = "photoshop";
    bt.body = "var main = " + script.toSource() + "; main();";
    bt.send(4);
    
    
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 5:09 AM   in reply to Paul Riggott

    I don't think this forum is working as it should…? Paul you getting any notifactions?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 5:13 AM   in reply to Muppet Mark

    Yes I'm getting the e-mails but this thread is missing bits, maybe a server problem Mark.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 5:18 AM   in reply to Paul Riggott

    I'll go check me settings… TVM

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points