Mobile app version of vmapp.org
Login or Join
Michele215

: Script to place a circle on the center of of all my strokes I have a design I'd like to laser cut and need to put a circle in the center of the red lines. Is there a way to place

@Michele215

Posted in: #AdobeIllustrator #IllustratorScripting

I have a design I'd like to laser cut and need to put a circle in the center of the red lines.

Is there a way to place a circle in the center of each line without having to do it manually and keeping the thickness editable?

For instance, if I change the thickness of the red line, the thickness of the circle would also change.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Michele215

3 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer715

You could try this:


Select a red line.
select>same>appearance
Open the Appearance palette.
Add a new stroke (button at the lower left of the palette)
effect>convert to shape>ellipse, change the size to absolute, then enter whatever numbers you want for the actual size
Open the Graphic Styles palette and create a new style.




You can now change the weight of every line and circle drawn with this style:


click on the style you made in the Graphic Styles palette, or select a path drawn using this style
visit the Appearance palette and select the individual strokes to modify them
open the Appearance palette's menu, do "redefine graphic style", everything linked to this style should change to match


This won't work if some of your lines that need a circle in their middle are curved.

10% popularity Vote Up Vote Down


 

@Moriarity648

The following solution is not automatic, but it will get your circles in the exact position.


Select your triangle or lines (whether a closed shape or not). Click Object > Path > Add anchor points. This will add an anchor at the exact centre of each line.
With Smart Guides enabled position horizontal and vertical guides at the anchors so that they intersect.
Use these guides to position your circles. With Smart Guides on, the circle centre will snap to the intersection.





To change all the line weights at the same time, select one red line, and click Select > Same > Stroke Color
Change the stroke thickness as desired.

10% popularity Vote Up Vote Down


 

@Cugini998

For a line the following holds true (but not many other shapes). Center of bounding box is equal to center of line. Now if we simply modify this script:
#target illustrator

var doc = app.activeDocument;
var sel = doc.selection;
var rad = 10;

for(var i = 0; i < sel.length; i++){
if(sel[i].typename == "PathItem"){
var obj = sel[i];
var center = obj.position;
center[0] += obj.width/2.0;
center[1] -= obj.height/2.0;
doc.pathItems.ellipse(
center[1]+rad,center[0]-rad,
2*rad, 2*rad,
false, false
);
}
}


Select red lines and run (with extendScript Toolkit).

Or you can do this fully automatically without a script just select the red lines:


(optional, see below) duplicate them
apply convert to shape ellipse, set values to absolute.
(optional) Expand


done. Alternatively you can just add another stroke on the line with a ellipse conversion, then no duplicate is needed

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme