Copy link to clipboard
Copied
Hello,
I am trying to find the equivalent of the Flex "Document.id" in the C++ SDK.
It seems to me that the UID of a document is always equal to 1 :
InterfacePtr<IApplication> application(GetExecutionContextSession()->QueryApplication());
InterfacePtr<IDocumentList> docList(application->QueryDocumentList());
PMString name;
for (int i=0; i < docList->GetDocCount(); i++)
{
IDocument* doc = docList->GetNthDoc(i);
if(nil == doc)
continue;
UIDRef myUIDRef = GetUIDRef(doc);
UID myUID = myUIDRef.GetDataBase()->GetRootUID();//or myUIDRef.GetUID()
doc->GetName(name);
printf("%dth doc : %d (%s)", i, myUID.Get(), name.GetPlatformString().c_str());
}
In Flex, it is incremental.
Thank you,
David
Copy link to clipboard
Copied
UID is unique in a database (document), UIDRef is unique in indesign.
UIDRef myUIDRef = document->GetDocWorkSpace();
UID myUID = myUIDRef.GetUID();
Copy link to clipboard
Copied
I've tried that too, but the UID seems to be always a 6 but I imagine it is normal since you say that an UID is unique inside a database.
I would like to have a graphical plug-in in Flex discussing with a C++ plug-in, what can I use to strictly identify a document in a list of opened documents, since two document can have the same name? Flex gives a incremental number with id in InDesign.Document class.
Copy link to clipboard
Copied
I'm not sure about flex api.
I think the index of app.documents.item(index) in javascript is same as documentList->GetNthDoc(index) in Plug-in api.
Copy link to clipboard
Copied
Sure, but that's not a secure method since the document is not properly identified.
Copy link to clipboard
Copied
UIDs are unique only within their database.
You could take the database pointer as unique value, but after close and open another document may receive the same memory location for its database. Another approach is a guid stored within the document meta data, but I don't know how InDesign will deal with duplicated files in this regard. The best would be you internally track open / close document signals and create your own completely unique IDs (with a mapping to the database pointer).
For either kind of unique value, you'd have to implement your own scripting property to hopefully expose it to Flex - assuming you go through CSXS.
Dirk
Copy link to clipboard
Copied
Yes, I've done something quite similar : just an attribute upon the Root XML element of the document to find it.
Copy link to clipboard
Copied
How would that work if you open the document "read-only"?
Dirk
Copy link to clipboard
Copied
You're right... but in my case it is impossible for the Flex plug-in to choose a read-only document.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now