Highlighted

illustrator Scripts

New Here ,
Jun 18, 2020

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], [nextX+wLine, nextY]]);

//add frame
var oFrame=myDoc.textFrames.add();
oFrame.contents="Your comment";
oFrame.top=nextY+10;
oFrame.left=nextX+wLine;

Topics

Scripting

Views

194

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

illustrator Scripts

New Here ,
Jun 18, 2020

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], [nextX+wLine, nextY]]);

//add frame
var oFrame=myDoc.textFrames.add();
oFrame.contents="Your comment";
oFrame.top=nextY+10;
oFrame.left=nextX+wLine;

Topics

Scripting

Views

195

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jun 18, 2020

Copy link to clipboard

Copied

Hi,

Please share your script to see what you have achieve till now. From there we can help you.

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jun 18, 2020

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?

 

Capture d’écran 2020-06-18 à 14.27.08.png

 

Capture d’écran 2020-06-18 à 14.28.01.png

 

Capture d’écran 2020-06-18 à 14.28.38.png

 

Capture d’écran 2020-06-18 à 14.31.12.png

 

Capture d’écran 2020-06-18 à 14.30.58.png

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jun 18, 2020

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.

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Enthusiast ,
Jun 21, 2020

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;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...