Copy link to clipboard
Copied
Hello AI friends! I'm curious if there's a way to make a custom style or SVG filter that would allow you to draw lines(bezier curves) from multiple dots. If I had several dots in a line, how could I apply a style/SVG filter to those dots that would draw lines from them. I'd love to hear any ideas you guys might have.
I've attached an image of what I'm going for.
Best,
Blake
1 Correct answer
Try
...// required some filled circles - all selected
// regards pixxxel schubser
var aDoc = app.activeDocument;
var aSel = aDoc.selection;
var len = 100;
var line = null;
for (i=0; i<=aSel.length-1; i++)
{
var pI = new Array (2);
pI[0] = aSel.left + aSel.width/2;
pI[1] = aSel.top - aSel.height/2;
line = aDoc.pathItems.add();
line.setEntirePath ( new Array( new Array ( pI[0], pI[1] ), new Array( pI[0]+len, pI[1]+len )));
line.pathPoints[1].rightDirection = new Array( pI[0]+len, pI[1]
Explore related tutorials & articles
Copy link to clipboard
Copied
Moved to Illustrator Scripting​
Copy link to clipboard
Copied
blakeferm​,
do your lines follow a certain rule? Which one is it? (start point is the center of a circle - but where is the end point)
Copy link to clipboard
Copied
Hi Pixxxel! Thank you so much for the reply. The lines would maintain their stoke width and can arc/curve outwards from the dot on a two point line. Start point of the line would be the dot and end point could be further away. The end point isn't too specific but it would be cool if it had distance to create a nice long line coming out from the dot.
I've been experimenting with custom brush styles that could be applied to a series of dots, but I'm having some issues getting the lines to simply arc away from the start point of the dot.
Best,
Blake
Copy link to clipboard
Copied
Your dots are single anchorpoints with stroke width - or circles with fill color and not stroked?
Can you upload an example file on a hoster of your choice please (dropbox or xup.in or …) ?
Copy link to clipboard
Copied
Hi there,
The dots are circles with fill color and no stroke. Here's a dropbox link to the AI file. Thanks so much!
Dropbox - AI Experiment - Simplify your life
Blake
Copy link to clipboard
Copied
You can see from my AI file how I'd love the lines to work from the right hand side example. You can also see some of the brush styles I've begun to test with.
Thanks so much!
Copy link to clipboard
Copied
Try
// required some filled circles - all selected
// regards pixxxel schubser
var aDoc = app.activeDocument;
var aSel = aDoc.selection;
var len = 100;
var line = null;
for (i=0; i<=aSel.length-1; i++)
{
var pI = new Array (2);
pI[0] = aSel.left + aSel.width/2;
pI[1] = aSel.top - aSel.height/2;
line = aDoc.pathItems.add();
line.setEntirePath ( new Array( new Array ( pI[0], pI[1] ), new Array( pI[0]+len, pI[1]+len )));
line.pathPoints[1].rightDirection = new Array( pI[0]+len, pI[1]+len);
line.pathPoints[1].anchor = new Array( pI[0]+len*1.2, pI[1]+len*0.8);
line.rotate(5*i, true, true, true, true, Transformation.BOTTOMLEFT);
line.filled = false;
line.stroked = true;
line.strokeWidth = 1;
line.strokeColor = aDoc.swatches[1].color;
}
This snippet draws a line (Bezier curve) from the middle of each circle using setEntirePath function.
Before:
After:
If that works for you
have fun
Copy link to clipboard
Copied
Hello my friend and sorry for the late reply. Hope you had a great weekend.
This solution looks awesome and I can't wait to try it out. Thank you for taking time to write/share it!
I'll ping you with updates on my end.
Best,
Blake
Copy link to clipboard
Copied
Hi Pixxxel! This script is awesome and I'm learning how to manipulate the different variables to get some cool effects. I'm curious how I'd change the color of the line.
I tried a couple things with this line 'line.strokeColor = aDoc.swatches[1].color;' but nothing seems to work. Any help is greatly appreciated
Best,
Blake
Copy link to clipboard
Copied
aDoc.swatches[4].color eg is red in a 'normal' document.
Or you use another syntax aDoc.swatches.getByName['Registration'] But this is not save for every document. The safest way is to check if a swatch exists, and if not - to create the swatch.
Are there helpful answers for you in this thread?
Copy link to clipboard
Copied
Awesome, thank you so much! I've marked the most helpful answers
Best,
Blake
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi Pixxxel,
We can mark this as resolved. Thank you so much for all of your help.
Best,
Blake

