Skip navigation
firefighter222
Currently Being Moderated

Can ExtendScript call a function in CS SDK?

May 9, 2010 10:09 AM

I suppose this could be done through BridgeTalk - but is there an easier way to have an ExtendScript function call a method in the new CS SDK? (Flash Builder)?

 

This might simplify porting a large amount of code that's js.   Also, it seems unless you do a C++ plug-in you don't have control over the menus.

 

Thx

 
Replies
  • Currently Being Moderated
    May 9, 2010 4:31 PM   in reply to firefighter222

    The easiest way is to define a function in your ExtendScript script like:

     

    var __controller = {};

     

    initWrapper = function( wrapper ) {
        __controller = wrapper;
    }

     

    Then, you can make a call from an ActionScript object like:

     

    var esi:HostObject = HostObject.getRoot( HostObject.extensions[ 0 ] );
    esi.initWrapper( this );

     

    Then, in ExtendScript, you can directly call AS functions on that object via the __controller reference.

     

    James

     
    |
    Mark as:
  • Currently Being Moderated
    May 9, 2010 4:54 PM   in reply to firefighter222

    You can set up menus in InDesign and Bridge.

     

    The host object stuff that James posted is the way to go for calling from ExtendScript; but, there are some idiosyncracies depending on the host app.

     

    What host app(s) are you using?

     

    Regards

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 1:11 PM   in reply to firefighter222

    Brad,

     

    Can I ask you to give me a day or so to get definitive answers? The guy I need to talk to is travelling today.

     

    Regards

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 4:10 PM   in reply to Bob Stucky

    Our buddies from the UK are finally managing to get home? (I've been thinking about them...)

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 4:24 PM   in reply to Harbs.

    Yes, just got an email from James that all made it back. We were wondering how it would go with the announcement about no flights to the IK on Saturday.

     

    Twas great to meet you. We never did get a lot of time to talk. I certainly hope the stuff you were doing to grow your business helped!

     

    Bob

     

     

    Harbs. tactfully suggested:

     

     

     

    Our buddies from the UK are finally managing to get home? (I've been thinking about them...)

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 4:41 PM   in reply to firefighter222

    I've managed to find out what I needed to know. First up, the menus...

     

    We have some libraries being added to the SDK soon. Soon enough that I wouldn't suggest bothering to do it on your own.

     

    As for calling from ExtendScript - I want to ask why you think you'll need to do that. Is it the porting process?

     

    It's really not as difficult as it seems at first. If you keep type checking turned on, you'll need to add type information to ExtendScript, and you'll need to set up an "app" analog. The cswa libs use "InDesign.app" instead of app, so if you have:

     

         public var app: Application = InDesign.app;

     

    as a public var in your class, it will solve that one.

     

    You can turn off type checking and pretty much just paste your ES code (so long as you have "app" defined). If you keep type checking on, it'll show you where all the issues are (usually those will just be warnings, not errors). Granted it takes time, but it's not difficult.

     

    There's a couple of other gotchas, like this one :

     

    var doc: Document = InDesign.app.activeDocument; // to set context of "doc"

     

    ALWAYS USE:

     

         var frame: TextFrame = doc.textFrames.item( 2 );

     

    NEVER USE:

     

         var frame: TextFrame = doc.textFrames[ 2 ];

     

    The bracket notation will fail. Remember that for InDesign's various collections (documents, textframes,pageitems, etc).

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 5:33 PM   in reply to firefighter222

    Ah...

     

    The coming library will give you access to  ID's events, and hence menus.

     

    As we're talking about interacting back to a UI,  you're going to want to port that 3rd party code.  Interacting with a Flex UI  from ExtendScript, while possible, would be architecturally wrong, and  would take significant effort. Possibly more than doing the port itself.  I would go ahead and take the pain now.

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    May 10, 2010 6:01 PM   in reply to Bob Stucky

    Yeah. It was great to meet you in person as well!

     

    Maybe we'll get more time to talk next time...

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2010 10:22 PM   in reply to Bob Stucky

    Hello Bob,

     

    when will this library be released?

     

    Best,

    Luca

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2010 12:04 AM   in reply to emerasoft-srl

    The engineers of the CS SDK have been working very hard for a long time. They all deserve a bit of a rest. [round of applause!] I expect you'll have to be patient a bit...

     

    Harbs

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2010 12:56 AM   in reply to Harbs.

    Yes, round of applause! I agree !! This is the most exciting feature of CS5 in my opinion

     

    Best,

    Luca

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2010 8:53 PM   in reply to emerasoft-srl

    For your reading pleasure, we've recently posted a cookbook entry which goes into detail on communicating between the CS SDK and ExtendScript. Check it out here: http://cookbooks.adobe.com/creative_suite_sdk. Also, feel free to add a recipe of your own.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points