2 Replies Latest reply on Jan 28, 2017 4:09 AM by Sergey Kritskiy

    Merged paths: lost subpaths and points with JSX

    Sergey Kritskiy Level 1

      Hi everyone,

       

      I've created several paths

      RmgdWS

       

      Then I run this code to log the number of subpaths and points

      for (var i = 0; i < activeDocument.pathItems[0].subPathItems.length; i++) {
          $.writeln("subpath: #" + i + "\t points: " + activeDocument.pathItems[0].subPathItems[i].pathPoints.length);
      }
      

       

      And I'm getting

      subpath: #0 points: 4
      subpath: #1 points: 4
      subpath: #2 points: 4
      

       

      Perfect. Then I do Merge Shape Components command and run the same code and I'm getting

       subpath: #0 points: 4
      

       

      Where're the other 2 subpaths? Or other 8 points?

      I'm not sure if that's a bug or intentional, but is there a way to find these lost subpaths/points or maybe to un-merge the combined path?

       

      Thanks,

      Sergey

        • 1. Re: Merged paths: lost subpaths and points with JSX
          Jarda Bereza Level 4

          It seems to that I can see same issue.

          I can't found this in DOM.

          Anyway I like more action manager. You can do more with AM and you have better chance to see correct values. But it's more difficult.

          If you want read values I recommend this:

          GitHub - JavierAroche/descriptor-info: JSX module to recursively get all the properties in an ActionDescriptor used in A…

           

          This can create object which looks like DOM approach but there is more properties. Anyway it is read-only. Example how to use it.

           

          // Include the JSON helper 
          #include "JSON.jsx"  // Include the descriptor-info module 
          #include "descriptor-info.jsx"     // ActionDescriptor example   
          var ref = new ActionReference();    //ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );    ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Path"), stringIDToTypeID("vectorMask") );    var desc = executeActionGet(ref);      // Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param  // Optional @param {Object} descFlags // Optional @flag {Boolean} reference - return reference descriptors. Could slighly affect speed. // Optional @flag {Boolean} extended - returns extended information about the descriptor. 
          var descFlags = {
               reference : true,
               extended : false 
          };   var descObject = descriptorInfo.getProperties( desc ); // If using descFlags > descriptorInfo.getProperties( desc, descFlags );   $.writeln(JSON.stringify(descObject, null, 4)); // Running in ExtendScript  // Running in Brackets with the Brackets-to-Photoshop extension // https://github.com/JavierAroche/brackets-to-photoshop // Brackets-to-Photoshop extension includes the JSON helper by default  $.writeln(descObject); 

           

          This forum sh** with my code, so here is undeformed form.

          [JavaScript] // Include the JSON helper #include "JSON.jsx" // Include the descriptor-info - Pastebin.com

           

          You need place JSON.jsx and descriptor-info.jsx in same folder as you script (or place their content inside your script).

          Then you can run:

          descObject.pathContents.pathComponents[0].pathComponent.subpathListKey[2].subpathsList.points[3].pathPoint.anchor.horizontal
          

           

          In: "subpathListKey" you should see your subpaths which are merged into one path inside path-layer. Paths which are not merged should be in "pathComponents"

          Descriptor is for selected layer vector mask.

          • 2. Re: Merged paths: lost subpaths and points with JSX
            Sergey Kritskiy Level 1

            Ooooh, thank you so much, Jarda, I forgot to try to find the points with AM-code