[Pythonmac-SIG] make new object on Mac
hengist.podd at virgin.net
Sat Oct 22 12:07:15 CEST 2005
Zhi Peng wrote:
>Did any of you make a new object such as document, textframe etc by using MacPython appscript for Adobe InDesign CS2?
>For example, I have document object docObj
>should I use
>newPage = docObj.add() or docObj.make .... or something else
Use the 'make' command to create new objects ('add' only applies to existing objects). Figuring out the appropriate insertion location reference for the 'at' parameter is usually the tricky bit, as the rules vary from application to application and most vendors woefully under-document such details. (I believe Adobe provide some good scripting documentation for ID though, so check that out if you've not already done so.) It sometimes takes a bit of experimentation to find a reference form that the application will accept; some are more finicky than others, though ID should be one of the better ones.
For example, to insert a new page after all the existing pages, it'll be something like:
id = app('InDesign')
docObj = id.documents
Tip: For convenience, appscript also allows you to write that last line as:
See the section on special cases in the 'Application Commands' chapter of the appscript manual.
To insert a new page between the first and second pages, it'd be something like:
And so on. (I don't have a copy of ID to hand to check these, but hopefully they're correct, or at least point you in the right direction. If not, hopefully there's an ID user here who can provide the correct version.)
More information about the Pythonmac-SIG