[Pythonmac-SIG] get reference

has hengist.podd at virgin.net
Wed Oct 26 21:53:06 CEST 2005

Zhi Peng wrote:

>But with app('Adobe InDesign CS2'), it
>does not work well. All application can accept the
>commands but not the reference such as
>cs = app("Adobe InDesign CS2")
>cs.activate()   ----------------- works
>cs.open("filepath_with_name")   ------- works
>doc = cs.documents[0]             -------- works

Shouldn't work, because elements of application objects are always 1-indexed. (It's not impossible that a scriptable app might try to 'helpfully' interpret a 0 index rather than just flagging it as an error, but I'm not aware of any that do.) However, note that a bad reference won't raise an error until you actually use it in a command, at which point the application will raise an Apple event error of [usually] type -1728 which appscript reports as a CommandError.

>page = doc[1]                          -------- works

I think you meant 'page = doc.pages[1]'

>textframe.contents="HELLO"      ------ not work

Not supported.

The following should work, assuming it's semantically correct and identifies an existing object:


If it doesn't, check the AppleScript equivalent just to make sure that it works:

tell application "Adobe InDesign CS2"
	set contents of textframe 1 of page 1 of document 1 to "HELLO"
end tell

Then tell me what version of appscript you're using and post a traceback so I can see what the error actually is. Like I say, it may just be that you need to upgrade to the latest version of appscript, though I'd like to make sure it's not something else.

>I wonder if I missed something since I get only a
>small __init__.py file while I used pythonw
>getsuitmodule.py for Adobe InDesign CS2. But same
>command applied to TextEdit and Finder, iTune, I get a
>few big file include __init__.py.

I wouldn't know about that. gensuitemodule has always been rather flaky and clumsy; however, appscript has no connection to it or aetools/aepack/aetypes.


More information about the Pythonmac-SIG mailing list