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

Automated way to draw lines from multiple dots in AI

Community Beginner ,
Jan 04, 2019 Jan 04, 2019

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.

dot_lines.jpg

Best,
Blake

TOPICS
Scripting
1.7K
Translate
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 1 Correct answer

Community Expert , Jan 04, 2019 Jan 04, 2019

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]

...
Translate
Adobe
Community Expert ,
Jan 04, 2019 Jan 04, 2019

Moved to Illustrator Scripting​

Translate
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 ,
Jan 04, 2019 Jan 04, 2019

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)

Translate
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 Beginner ,
Jan 04, 2019 Jan 04, 2019

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

Translate
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 ,
Jan 04, 2019 Jan 04, 2019

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 …) ?

Translate
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 Beginner ,
Jan 04, 2019 Jan 04, 2019

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

Translate
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 Beginner ,
Jan 04, 2019 Jan 04, 2019

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!

Translate
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 ,
Jan 04, 2019 Jan 04, 2019

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:

drawLineFromCirclesCenterpoint1.png

After:

drawLineFromCirclesCenterpoint2.png

drawLineFromCirclesCenterpoint3.png

If that works for you

have fun

Translate
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 Beginner ,
Jan 07, 2019 Jan 07, 2019

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

Translate
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 Beginner ,
Jan 07, 2019 Jan 07, 2019

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

Translate
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 ,
Jan 07, 2019 Jan 07, 2019

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?

Translate
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 Beginner ,
Jan 07, 2019 Jan 07, 2019

Awesome, thank you so much! I've marked the most helpful answers

Best,
Blake

Translate
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 ,
Jan 13, 2019 Jan 13, 2019

Hi blakeferm​,

do you need further assistance? Or is your problem solved?

Translate
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 Beginner ,
Jan 14, 2019 Jan 14, 2019
LATEST

Hi Pixxxel,

We can mark this as resolved. Thank you so much for all of your help.

Best,
Blake

Translate
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