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

Is there any way to assign a global value to a document (object)?

Engaged ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

I'll try and keep this short. I need to set a global in my photoshop application to tell my program if the document has been opened externally, I need this for a few reasons:

1. If it's opened externally I can't have the user change the canvas size (Lock the opened doc canvas size).

2. I need to provide a call back to my calling application to tell it whenever I save (That way it can update the UI with the new saved image) OR simply assign a global on the PS application to query if the doc was opened.

I was thinking of prefixing the Document name with a Character so I can just look up the document name and know if it's been opened by an external app.

   

     //Javascript

    var documentName = "!" + ActiveDocument.Name;

    //c++

    if(DocumentNameContainsBash(&documentName))

EDIT: I've just realized that the doc name is read only... I can't save over it with a new name either...

But I would love to be able to check if it's been opened though some kind of document object that I could return like:

    hasDocumentOpenedExternal(&document);

Is this possible in JS?

TOPICS
Actions and scripting

Views

522

Translate

Translate

Report

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

correct answers 1 Correct answer

Engaged , Jul 31, 2017 Jul 31, 2017

I got it:

              //Set a global actionDesc

        app.DoJavascript("var desc = new ActionDescriptor(); desc.putString( 0 , \"yes\"); app.putCustomOptions('mmm', desc, true);");

                 //Return global actionDesc

        app.DoJavascript("var desc2 = app.getCustomOptions('mmm'); var s = desc2.getString(0);");

Votes

Translate

Translate
Adobe
Engaged ,
Jul 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

LATEST

I got it:

              //Set a global actionDesc

        app.DoJavascript("var desc = new ActionDescriptor(); desc.putString( 0 , \"yes\"); app.putCustomOptions('mmm', desc, true);");

                 //Return global actionDesc

        app.DoJavascript("var desc2 = app.getCustomOptions('mmm'); var s = desc2.getString(0);");

Votes

Translate

Translate

Report

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