Skip to main content
Inspiring
February 21, 2024
Answered

Are TextFrame IDs immutable?

  • February 21, 2024
  • 7 replies
  • 1460 views

Can TextFrame IDs change, after the TextFrame has been created?

 

I have pairs of related TextFrames (in the same document) and want to store the ID of the other frame in a label. This only works, if the IDs don’t ever change.

 

The API reference describes ID as »The unique ID of the TextFrame«.
Document.id is described the same way (»The unique ID of the Document.«) and these IDs are assigned each time a document is opened.

 

I did a few tests, and my ID did not change when:

  • Adding other PageItems
  • Saving, Saving as, Saving as Copy
  • Opening a cc22 file in cc24
  • Restarting InDesign

 

However, it did change after exporting to idml (which I can live with).

 

Alhough it appears that IDs do not change, can anyone actually confirm, that this is the case?
And it would be interesting to know if this also applies to all (?) other IDs.

 

This topic has been closed for replies.
Correct answer C330 S

Tanks all for your replies!

 

by chance I found the following from Harb in this thread:

 

The ids do not change. They correspond to the UIDs on the C++ level

which is how InDesign keeps track of objects...

 

So it does seem to be generally accepted that IDs never change.

Unless the object is ›rebuilt‹ in some way. This could be due to:

  • Cutting and pasting
  • Export to / Import from IDML or IDMS

 

IDs also do not change, if you change the type of an object (e.g. Oval => TextFrame).

 

Of course this dosn’t apply to document-IDs (probably also book-IDs).

These are assigned on the fly, each time a document (or book ?) is opened. 

 

I have tried to summarise everything here, so I will mark this as the accepted answer.
I hope this isn't bad style – I don't want to steal anyone's laurels.

 

Regards,

Martin

7 replies

Robert at ID-Tasker
Legend
March 1, 2024

@C330 S 

 

Do not store original IDs - use your own IDs stored in the Label - you can of course use original IDs set by InDesign on the first run - then make a list of all objects and their Labels - and pair them at the begining of your script.

 

I've done it this way when creating online system for catalogues for STANLEY.

First run of my tool would get IDs set by InDesign and set as a label - "mark" them - then on the next run - I woud read all labels & current IDs and pair them for quicker access via .itemByID().

So "my" IDs would be stored in the online database - after first run - and when someone changed text online - I had no problem locating correct object in the current document and update.

 

Robert at ID-Tasker
Legend
March 1, 2024

@C330 S

 

Then, you can use .insertLabel(key, value) & .extractLabel(key) instead of .label

 

Community Expert
March 1, 2024

InDesign document is basically sort of a database and the id's are the primary keys to identify the objects in this database. So if it is the same object the id would not change with any operation. Things like copy paste creates a new object so new ID. IDML export is akin to rebuiliding of the DB from scratch in my opinion so ID's would be changed but could have remained the same as well.

-Manan

-Manan
C330 SAuthorCorrect answer
Inspiring
March 1, 2024

Tanks all for your replies!

 

by chance I found the following from Harb in this thread:

 

The ids do not change. They correspond to the UIDs on the C++ level

which is how InDesign keeps track of objects...

 

So it does seem to be generally accepted that IDs never change.

Unless the object is ›rebuilt‹ in some way. This could be due to:

  • Cutting and pasting
  • Export to / Import from IDML or IDMS

 

IDs also do not change, if you change the type of an object (e.g. Oval => TextFrame).

 

Of course this dosn’t apply to document-IDs (probably also book-IDs).

These are assigned on the fly, each time a document (or book ?) is opened. 

 

I have tried to summarise everything here, so I will mark this as the accepted answer.
I hope this isn't bad style – I don't want to steal anyone's laurels.

 

Regards,

Martin

Peter Kahrel
Community Expert
Community Expert
February 21, 2024

> And it would be interesting to know if this also applies to all (?) other IDs.

 

Yes, that goes for all IDs. 

Peter Kahrel
Community Expert
Community Expert
February 21, 2024

If you cut and paste a textFrame, the pasted frame would get a new ID

 

Yet another reason to avoid cut-and-paste like the plague!

rob day
Community Expert
Community Expert
February 21, 2024

Hi @C330 S , If you cut and paste a textFrame, the pasted frame would get a new ID.

davidt12412601
Inspiring
February 21, 2024

I suppose that means that object ids truly are immutable, and that a cut/paste operation actually creates a new object then applies certain properties from the original?

rob day
Community Expert
Community Expert
February 21, 2024

The ID property is read only so it can’t be changed or set via scripting. Not sure you could prevent a cut and paste—maybe with a listener?

davidt12412601
Inspiring
February 21, 2024

I don't know about text frame ids, but our workflow depends on page ids, which I can confirm are immutable. As you pointed out, export to idml will change them, but I assume that's because when opening an idml file InDesign is actually importing the idml file and creating a new document from its content.