2 Replies Latest reply on Jun 2, 2010 10:43 PM by bestwave

    How to get PathPointInfo or SubPathInfo?

    bestwave Level 1

      I am trying to modify a work path.

       

      These statements all work:

       

      get application.activeDocument().pathitems(1).subpathitems.item(1).pathpoints.item(1).anchor( )
      -- [265.5000, 74.0000]
      get application.activeDocument().pathitems(1).subpathitems.item(1).pathpoints.item(1).rightdi rection()
      -- [153.6624, 74.0000]
      get application.activeDocument().pathitems(1).subpathitems.item(1).pathpoints.item(1).leftdir ection()
      -- [377.3376, 74.0000]

       

      But, these are read only!  In order to modify the path, you have to have PathPointInfo or SubPathInfo.

       

      The documentation also says EntireSubPath will also work, but can't get there either.

       

      Does anyone know how to get to these values?

       

      Thank you!

        • 1. Re: How to get PathPointInfo or SubPathInfo?
          Michael L Hale Level 5

          You can't edit an existing path using scripting. You will need to read the path and convert into subPathInfo and pathPointInfo objects and either modify while converting or later after the conversion. Then delete the old path and make a new one from the edited info.

           

          Here is an example of extracting the info.

          function extractSubPathInfo(pathObj){
              var pathArray = new Array();// each element can be used as the second arugment in pathItems.add ie doc.pathItems.add("myPath1", [pathArray[0]]);
              var pl = pathObj.subPathItems.length;
              for(var s=0;s<pl;s++){
                  var pArray = new Array();
                    for(var i=0;i<pathObj.subPathItems[s].pathPoints.length;i++){
                       pArray[i] = new PathPointInfo;
                       pArray[i].kind = pathObj.subPathItems[s].pathPoints[i].kind;
                       pArray[i].anchor = pathObj.subPathItems[s].pathPoints[i].anchor;
                       pArray[i].leftDirection = pathObj.subPathItems[s].pathPoints[i].leftDirection;
                       pArray[i].rightDirection = pathObj.subPathItems[s].pathPoints[i].rightDirection;
                    };
                  pathArray[pathArray.length] = new Array();
                  pathArray[pathArray.length - 1] = new SubPathInfo();
                  pathArray[pathArray.length - 1].operation = pathObj.subPathItems[s].operation;
                  pathArray[pathArray.length - 1].closed = pathObj.subPathItems[s].closed;
                  pathArray[pathArray.length - 1].entireSubPath = pArray;
              };
              return pathArray;
          };
          var myPathInfo = extractSubPathInfo(app.activeDocument.pathItems.getByName('Path 1'));
          var myPathItem = app.activeDocument.pathItems.add("myNewPath", myPathInfo);
          
          1 person found this helpful
          • 2. Re: How to get PathPointInfo or SubPathInfo?
            bestwave Level 1

            Michael

             

            Thank you for your very helpful response.  Just knowing that a path cannot be modified in scripting would have saved me days of trying!

             

            I also thank you for your example of how to read the path points and create a new, modified path from it.

             

            The problem is that this is related to my earlier question from a couple of days back....  what I really need to do is put text on a circular path.  I know the path coordinates I need, but couldn't come up with a way to "stick" the text to a path I made myself, so I was trying to put text on a random path, then modify the coordinates to make it the right size.

             

            Now that I know it won't work that way, I can concentrate on finding a way to attach text to a new circular path.

             

            By the way, scriptlistener creates a script when you add text to a work path, which is 1300+ lines long, and does not work when you play it back!

             

            Thanks again, I will keep researching!!