Skip to main content
brian_p_dts
Community Expert
Community Expert
August 11, 2022
Answered

[JSX] Remembering locked layers/pathitems/groupitems for easy recall across documents

  • August 11, 2022
  • 3 replies
  • 452 views

Hi all, 

 

I'm working on a script for some complex files with multiple layers, sublayers, groups, pathitems etc. To operate on the items I need to, I first iterate through the doc and unlock and make visible/unhidden all page items and layers. For the purposes of the script, I am duplicating some of the main layers to a new document. Rather than having to iterate through all page items again, is there an easier way to recall which may have been locked? I thought about passing the specific items to a layer, but since I'm copying to a new doc, I doubt those items would be valid. Is there a way to generate a list of previously locked items and their index chain within their respective parent? Or some other more obvious way that I might not be considering? Appreciate it. 

 

This topic has been closed for replies.
Correct answer Charu Rajput

Hi @brian_p_dts 

What about keeping an uuid of the items in two separate array one for visibility and another for locked items. And to fetch you can you use getPageItemFromUuid method.

Example:

 

var _id = app.selection[0].uuid;
var _itemUsingUUID = app.activeDocument.getPageItemFromUuid(_id);

 

You don't need to traverse all pageitems instead only those that are present in the stored array for visibility and locked. 

 

uuid is equivalent to the id,

getPageItemFromUuid is equivalent to the itemByID in the Indesign.

 

3 replies

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
August 11, 2022

Hi @brian_p_dts 

What about keeping an uuid of the items in two separate array one for visibility and another for locked items. And to fetch you can you use getPageItemFromUuid method.

Example:

 

var _id = app.selection[0].uuid;
var _itemUsingUUID = app.activeDocument.getPageItemFromUuid(_id);

 

You don't need to traverse all pageitems instead only those that are present in the stored array for visibility and locked. 

 

uuid is equivalent to the id,

getPageItemFromUuid is equivalent to the itemByID in the Indesign.

 

Best regards
brian_p_dts
Community Expert
Community Expert
August 11, 2022

Good suggestion. I will see if the uuid carries over when I duplicate the hashed item to a new doc. 

brian_p_dts
Community Expert
Community Expert
August 11, 2022

I guess alternative if it doesn't would be to store the existing item name and the uuid as a key:value object in the array and rename it to it's uuid before duplicating, then rename it back using the object value. 

m1b
Community Expert
Community Expert
August 11, 2022

Hi @brian_p_dts, do you need to keep track of these objects and properties over the course of a single script execution? Or between multiple script executions? Eg one script to unlock/unhide, and another script to lock/hide again later.

-Mark

brian_p_dts
Community Expert
Community Expert
August 11, 2022

It's all in the same script but the items are duplicated to a new document. @femkeblanco if I use tags, wouldn't I have to reiterate through everything anyway to read the tag, or can you call an item tag? 

femkeblanco
Legend
August 11, 2022

What about adding a tag object to each item with values such as "was locked" or "was invisible"?