2 Replies Latest reply on Nov 16, 2015 9:35 AM by tlumbis

    Graphic Line Anchors...

    tlumbis

      The script below from GitHub (Graphic Lines · fabiantheblind/auto-typo-adbe-id Wiki · GitHub) creates the path shown below...

       

      The anchor location for each point matches the position of the point before it.

       

      I want to create a path made only of straight lines and have been trying, unsuccessfully, to either remove the anchors or to make the anchor positions match the position of the point they're drawn from.

       

      Does anybody have any suggestions?

       

      Thanks very much for any help.

       

      gline.png

      var data = {

         "pw":100,

         "ph":100,

         "anchors":[

        [  0,50],

        [ 10,60],

        [ 20,40],

        [ 30,60],

        [ 40,40],

        [ 50,60],

        [ 60,40],

        [ 70,60],

        [ 80,40],

        [ 90,60],

        [100,50]

        ]

        };

       

         // we need a doc

         // use pw and ph from data

         var doc = app.documents.add({

        documentPreferences:{

        pageHeight:data.ph,

        pageWidth:data.pw

        }

        });

       

         // the page is already there

         var page = doc.pages.item(0);

       

         // create a graphicLine

       

         var gl = page.graphicLines.add();

       

         // loop thru the data.anchors

         for(var i in data.anchors){

         var point = gl.paths[0].pathPoints[i];

         /**

        * a graphicLine always has 2 pathpoints

        * so we need to add points only from the third

        * anchor from the data object

        */

       

         if(i < 2){

        point.anchor = data.anchors[i];

        }else{

        point = gl.paths[0].pathPoints.add();

        point.anchor =  data.anchors[i];

        }

       

         if((i != data.anchors.length - 1)&& i!=0)

       

        point.rightDirection = data.anchors[i-1];

        point.leftDirection = data.anchors[i];

        }

      Thanks very much for any help.

      gline.png