Skip to main content
Inspiring
April 14, 2023
Question

Duplicate Part of a Compound Path Question

  • April 14, 2023
  • 1 reply
  • 355 views

Hello All,

Is there a way Script wise that I can only duplicate the outermost path of a Compound Path?

My first attempt was to duplicate the whole compound path which worked... if I selected the Script manually... and did not work when I used the Action Panel to call the Script.


    var objectHeight = selectedObject.height;
    var objectWidth = selectedObject.width;
    var duplicatedObject = selectedObject.duplicate();
        duplicatedObject.left = selectedObject.left - (objectWidth * 2);
   app.activeDocument.selection = null;
    duplicatedObject.selected = true;
    app.executeMenuCommand("noCompoundPath");
    app.executeMenuCommand("ungroup");

 

This topic has been closed for replies.

1 reply

femkeblanco
Legend
April 15, 2023

This duplicates the topmost path in a selected compound path.  (The duplicate will still be within the compound path; if it should be out, it will have to be moved out.)

var dup = app.selection[0].pathItems[0].duplicate();
dup.position = [0, 0];

If you want to duplicate the bottommost path, change the path's index to app.selection[0].pathItems.length - 1.