Thursday, September 20, 2018

#1 2018-07-10 01:49:28 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 153

InDesign CC: Possible to coerce an object reference to a string?

HI:

I'm having a problem getting an object reference as text. For example, when I get the object reference of a rectangle, Script Editor returns something like:

     rectangle id 239666 of spread id 239314 of document id 108 of application "Adobe InDesign CC 2018"

Clearly, a string. And I'd like to paste that string into a Filemaker Pro text field.

But when I try to get that text or set the Filemaker field with it, I get an error like:

     "Can’t make «class crec» id 239666 of «class sprd» id 239314 of document id 108 of application \"Adobe InDesign CC 2018\" into type string."

Does anyone know how an object reference can be coerced to the text string as shown in Script Editor? Thanks for any insights!

k

Browser: Safari 605.1.15
Operating System: Mac OS X (10.12.6 beta 6)

Offline

 

#2 2018-07-10 05:01:48 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 819

Re: InDesign CC: Possible to coerce an object reference to a string?

Hi. If it's not enclosed within quotes, it isn't a string. Yours is a reference, and you can get one or more of its component properties; the first one is really all that's needed to re-reference it in the future.

Applescript:


set AppleScript's text item delimiters to ", "

tell application "Adobe InDesign CS3"'s document 1 to set {itemID, pageID, spreadID} to rectangle 1's {id, parent's id, parent's parent's id}

set thing to result as text
set AppleScript's text item delimiters to ""
thing

Offline

 

#3 2018-07-11 08:52:03 am

kerflooey
Member
Registered: 2011-07-07
Posts: 153

Re: InDesign CC: Possible to coerce an object reference to a string?

Hi Marc:

> If it's not enclosed within quotes, it isn't a string

Ah, now that you mention it, I see what you mean. I just think it's weird that the text is' on the screen in the result but there is no option to just grab that displayed text, as text, and paste it somewhere else.

I finally figured out that I can simply get and store the rectangle ID (which I see you have in your useful snippet!) and from there get everything else.

Thanks!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)