Skip to main content
Participating Frequently
September 29, 2023
Answered

PathItem creation

  • September 29, 2023
  • 1 reply
  • 289 views

I'm trying to create a function that checks all the elements of a pathitem and reproduces it, but I'm not able to create the last edge that closes it, be it a straight line or a curve, below I leave an image of the result, could anyone give me some tip?

 

function RecreateDieCut () {
   var doc = app.activeDocument;

   var pathItemOriginal = doc.pathItems.getByName("path")
 
   var doc = app.documents.add();

   var novoPathItem = doc.pathItems.add();

   for (var i = 0; i < pathItemOriginal.pathPoints.length; i++) {
      var pathPointOriginal = pathItemOriginal.pathPoints[i];
      var pathPointNovo = novoPathItem.pathPoints.add();
     
      pathPointNovo.anchor = pathPointOriginal.anchor;
      pathPointNovo.leftDirection = pathPointOriginal.leftDirection;
      pathPointNovo.rightDirection = pathPointOriginal.rightDirection;
      pathPointNovo.pointType = pathPointOriginal.pointType;
   }
 
}

RecreateDieCut();
This topic has been closed for replies.
Correct answer CarlosCanto

if the original path is closed add this after your loop

 

novoPathItem.closed = true;

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
September 29, 2023

if the original path is closed add this after your loop

 

novoPathItem.closed = true;