Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Unique identifiers for opened documents

Guest
Jun 15, 2011 Jun 15, 2011

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

TOPICS
SDK
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 15, 2011 Jun 15, 2011

UID is unique in a database (document), UIDRef is unique in indesign.

UIDRef myUIDRef = document->GetDocWorkSpace();

UID myUID = myUIDRef.GetUID();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 16, 2011 Jun 16, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 16, 2011 Jun 16, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 16, 2011 Jun 16, 2011

Sure, but that's not a secure method since the document is not properly identified.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 17, 2011 Jun 17, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 17, 2011 Jun 17, 2011

Yes, I've done something quite similar : just an attribute upon the Root XML element of the document to find it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 17, 2011 Jun 17, 2011

How would that work if you open the document "read-only"?

Dirk

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 17, 2011 Jun 17, 2011
LATEST

You're right... but in my case it is impossible for the Flex plug-in to choose a read-only document.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines