Skip to main content
Known Participant
January 21, 2011
Question

Accessing scriptclasses from within the sdk

  • January 21, 2011
  • 1 reply
  • 484 views

Hi,

I' m wondering if it is possible to access the classes that are available thru the scripting api. Example:

In javascript i could write (this is just an example):

var doc = app.documents[0];

var storyList = doc.stories;

var tsrList = storyList[0];

var myTextStyleRange = tsrList[0];

To do the same thing in the sdk, you need a lot more code. The sdk has even no equivalent, out of the box, for the object "TextStyleRange".

In fact, what is presented as a "TextStyleRange" object to i.e. JavaScript, this has probabely a wrapper class in the sdk that keeps track of the indexes in a ITextModel with a continuous range of same layout characteristics. My point is: every object or function in JS must be mapped with 'something' in the sdk.

It would be nice if it was possible to use those 'somethings' from within the sdk to simplify things. Often, i don't need all the detail the sdk offers me. If i just want to move a pageitem from x,y to a,b i have to access details in the sdk that are 'overhead' for the 'simple' thing i want to do.

So, is there a possibility to do this? Is this somewhere documented? Are there reasons not to do it?

Any thoughts would be much appreciated!

Thanks in advance,

Bart Devos.

This topic has been closed for replies.

1 reply

Legend
January 23, 2011

There used to be something called high-level API. Abandoned ages ago because most of us preferred the "real thing" or went to scripting.

TextStyleRange like all the other Text scripting objects are second class citizens of the object model - they are created only on the fly as "proxy" objects. On the down side that means they consume memory until the document is released/saved/closed, and may fall apart (point to the wrong chunk of text) after any manipulation in preceding text. Besides the implementation is overkill by several degrees - each instance (I think it was kTextScriptingSuiteBoss) is the equivalent to a whole selection suite boss.

That said, you can use IScriptUtils to access kScriptInfoManagerBoss.

IScriptRequestHandler is aggregated there to execute script requests.

Be warned that constructing such script requests also has some learning curve, and the interfaces in the scripting area are extremely unstable across InDesign versions. Every other version renames methods, classes, adds or removes arguments. You will need plenty preprocessor conditions for cross-version code.

From the plugin side I only use that approach where the official interfaces do not work and the working interfaces (as used by scripting) are not exposed. One concrete case is TOP (type on path).

Dirk

Known Participant
January 24, 2011

Thank you, Dirk, for your answer.

Indeed if this path comes with memory penalties and extra complexity, it doesn't serve the goal to simplify things.

Thanks for your insights.

Bart Devos.