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

[CS5 - JS] wrong error app.activeDocmunet = there is no document

Explorer ,
Apr 22, 2011 Apr 22, 2011

Hi all

I call a function by onClick function in a palette Window.

In this function i try to check "app.documents.length" and the result is 1

But, if I check "app.activeDocument" the result is "there is no document"


If I set a "MyDoc = app.documents[0]" and I check MyDoc.path, again the result is "there is no document" even if MyDoc is a document.

it's a nonsense

Someone can help me?

TOPICS
Scripting
1.7K
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
Adobe
Community Expert ,
Apr 22, 2011 Apr 22, 2011

it doesn't work with palettes, only dialogs can do that. You only have one shot to do what you need to do...before you display the palette. Once it displays, it breaks the connection with the app.

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
Explorer ,
Apr 26, 2011 Apr 26, 2011

In InDesign it works differently.

I need a non-modal window for my Tool.

No workaround I suppose.

The only way is to run the script every time, can I apply a shortcut to let the user start my script?

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
Explorer ,
Apr 26, 2011 Apr 26, 2011

... also the customization of shortcuts to call my script is impossible.

Now I would like to customize the menu adding my own submenu that can call my script.

Someone knows if it is possible just lik in InDesign?

thanks

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
Guide ,
Apr 26, 2011 Apr 26, 2011

Adding a shortcut to scripts can be done by calling them from an action… Its a major let down in scripting this app and this too is plagued by a long time bug of the action forgetting the script path at quit… So it only lasts for the session… I was hoping that harb's scripbay was going to get shortcuts added as numerous people request it… I have been thinking of making a palette that shortcuts to the loaded scripts and add keyboard listener events to trigger them. The app should also have 'events' added to it. There is much that I wish was more like ID…

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
Enthusiast ,
Apr 28, 2011 Apr 28, 2011
LATEST

With Illustrator, you should use BridgeTalk in a palette Window, you function will be like this:

function onClick(){      var btMsg = new BridgeTalk();      btMsg.target = "illustrator";      btMsg.body = "app.activeDocument.save();";//or do something else.      btMsg.onResult = function( resultMsg ) {           $.writeln("Result = " + resultMsg.body);      }      btMsg.onError = function( errorMsg ) {           $.writeln("Error = " + errorMsg.body);      }      btMsg.send(); }

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