• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can someone share script that draw line between centers of two elipses

Explorer ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

I need a script that draws line (stroke: 1, yellow) between center of two randomly placed <Ellipse> objects on the artboard. Ellipses size is 10x10 and they cannot be symbols. Elipses cannot have different names, there name should be <Ellipse> .

 

My goal is to select the two green ellipses, run the script and get the line between the centers.

 

End goal example: 

dsa.JPG

 

TOPICS
Scripting

Views

312

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
community guidelines

correct answers 2 Correct answers

Community Expert , Apr 13, 2022 Apr 13, 2022

You may use this action:

 

Connector 1

 

Instruction:

 

- Download and unzip the file
- In the Actions palette, import the action set connector_1.aia
- Select two circles (or any other shape)
- Run the action connector_1

 

Votes

Translate

Translate
Guide , Apr 13, 2022 Apr 13, 2022
// select 2 ellipses
var s = app.selection;
var path1 = activeDocument.pathItems.add();
path1.setEntirePath([[s[0].left + s[0].width / 2, s[0].top - s[0].height / 2], 
                     [s[1].left + s[1].width / 2, s[1].top - s[1].height / 2]]);
var color1 = new RGBColor;
color1.red = color1.green = 255;
color1.blue = 0;
path1.strokeColor = color1;
path1.strokeWidth = 1;

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

You may use this action:

 

Connector 1

 

Instruction:

 

- Download and unzip the file
- In the Actions palette, import the action set connector_1.aia
- Select two circles (or any other shape)
- Run the action connector_1

 

Votes

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
community guidelines
Explorer ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

Thank you!

It worked properly besides it makes the line green.

Thank you for the fast response!

 

Quick question. Do you think the action can be modified for the line to be yellow and below the two selected circles?

 

Thank you in advance for your time! You are amazing. 🙂

Votes

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
community guidelines
Community Expert ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

LATEST

Yes, that's possible, of course.

 

See: Connector 2

 

Votes

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
community guidelines
Guide ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

// select 2 ellipses
var s = app.selection;
var path1 = activeDocument.pathItems.add();
path1.setEntirePath([[s[0].left + s[0].width / 2, s[0].top - s[0].height / 2], 
                     [s[1].left + s[1].width / 2, s[1].top - s[1].height / 2]]);
var color1 = new RGBColor;
color1.red = color1.green = 255;
color1.blue = 0;
path1.strokeColor = color1;
path1.strokeWidth = 1;

Votes

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
community guidelines
Explorer ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

Thank you for the script and your time! Have in mind that something does not work in it. But I already got a solution to my problem from the previous comment.

 

Thank you again for your time I really appreciate it!

Capture.JPG

Votes

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
community guidelines
Community Expert ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

quote

Have in mind that something does not work in it.

 

Capture.JPG


By @D.S..


your top layer must be visible and unlocked to avoid that error

Votes

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
community guidelines
Explorer ,
Apr 13, 2022 Apr 13, 2022

Copy link to clipboard

Copied

Ok I have tested it and it is working the way you mentioned.

 

Thank you! 🙂

Votes

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
community guidelines
Explorer ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

Is it possible to modify the script to lock the line only after creating it?

Votes

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
community guidelines
Community Expert ,
Apr 14, 2022 Apr 14, 2022

Copy link to clipboard

Copied

here you go

 

// select 2 ellipses
var s = app.selection;
var path1 = activeDocument.pathItems.add();
path1.setEntirePath([[s[0].left + s[0].width / 2, s[0].top - s[0].height / 2], 
                     [s[1].left + s[1].width / 2, s[1].top - s[1].height / 2]]);
                     
path1.move (s[s.length-1], ElementPlacement.PLACEAFTER);
                     
var color1 = new RGBColor;
color1.red = 255;
color1.green = 255;
color1.blue = 0;
path1.strokeColor = color1;
path1.strokeWidth = 1;

path1.locked = true;

 

Votes

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
community guidelines