Copy link to clipboard
Copied
Hello,
When creating a Script, is it possible to create an Object + Text?
Unfortunately, when I do this action: I draw a line and write text, next to this line to create a caption.
But the text doesn't appear when I launch the script.
Do you have an advice or a tip to generate text on scripts?
Thank you
This is script to create a line and frame to a selection object:
//get target doc
var myDoc = app.activeDocument;
//get selection object
var oTarget=myDoc.selection [0];
//get pos of selection object
var x=oTarget.left;
var y=oTarget.top;
var w=oTarget.width;
var h=oTarget.height;
//cal postion of line and frame.
var nextX=x+w ;
var nextY=y - (h/2);
var wLine=50;
// add aline
var myLine = myDoc.pathItems.add();
myLine.stroked = true;
myLine.setEntirePath([[nextX, nextY], [nextX, nextY], [nextX+wLine, nextY], [ne
Copy link to clipboard
Copied
Hi,
Please share your script to see what you have achieve till now. From there we can help you.
Copy link to clipboard
Copied
Hello,
Thanks for your response,
As you can see on the pictures below, I wanted to use the script tool, to create captions on my work, using a shortcut. (CMd+Maj+F1)
During the process I create a line and text, but when I execute the script, only the line is appearing, i would like both, line and text, is there a method to do it or impossible using scripts?
Copy link to clipboard
Copied
Hi,
I am not 100% sure. May be someone else from our team give your better explanation. But I have tried your steps and found that "Textframe" creation is not recorded in the actions. Therefore, when you exceute your action, textframe is not created. May be creating textframe is not recordable. I have tried in latest version of Illustrator.
I am not aware if this can be done in some another way using actions. Let's wait till someone else see this post.
Copy link to clipboard
Copied
This is script to create a line and frame to a selection object:
//get target doc
var myDoc = app.activeDocument;
//get selection object
var oTarget=myDoc.selection [0];
//get pos of selection object
var x=oTarget.left;
var y=oTarget.top;
var w=oTarget.width;
var h=oTarget.height;
//cal postion of line and frame.
var nextX=x+w ;
var nextY=y - (h/2);
var wLine=50;
// add aline
var myLine = myDoc.pathItems.add();
myLine.stroked = true;
myLine.setEntirePath([[nextX, nextY], [nextX, nextY], [nextX+wLine, nextY], [nextX+wLine, nextY]]);
//add frame
var oFrame=myDoc.textFrames.add();
oFrame.contents="Your comment";
oFrame.top=nextY+10;
oFrame.left=nextX+wLine;