Thursday, August 28, 2014

#1 2012-02-09 01:27:01 pm

SuperMacGuy
Member
From: Amish Country, Lancaster, PA
Registered: 2004-06-23
Posts: 416
Website

So what IS the "expected type" (specifically InDesign)

This one is really bothering me, because I can't understand what is really wrong, AND I work in InDesign all the time and this has never not worked before. BUT I'm calling a script from Objective-C, and that seems to work fine overall (or not?) In my script class I have 2 methods so far. One method gets the contents of a text frame on an InDesign document. The other is trying to place an image onto the first page of the document. The first method works great. The other method is getting called and goes through all the steps except the "place" command is giving me this error:

*** -[ScriptMethods placeImgInDoc:codeDestination:]: Can’t make «class page» id 191 of «class sprd» id 186 of document id 3 of application "Adobe InDesign CS5" into the expected type. (error -1700)

In a very shortened nutshell here's the code I'm using:

Objective-C
[asocScripts placeImgInDoc:[url path] codeDestination:fullString];

Applescript:



on placeImgInDoc_codeDestination_(imageURL, codeLoc)
       
       tell me to log imageURL
       tell me to log codeLoc
       
       set imageURL to POSIX file imageURL
       set codeLoc to codeLoc as string
       
       tell application "Adobe InDesign CS5"
           if exists document 1 then
               tell document 1    
                   tell page 1
                       display dialog "6"
                       set someResult to place imageURL place point {0, 0} showing options no with properties {label:codeLoc}
                       display dialog "7"
                       --adding a label to the object results in
                       --the IMAGE not the frame getting a label
                       set label of parent of item 1 of someResult to "qrCode"
                       display dialog "9"
                       
                   end tell
               end tell --document 1
           end if --exists document 1
       end tell
       
   end placeImgInDoc_codeDestination_


Scripts for InDesign: http://chris.paveglio.com
ASOC & Cocoa, specializing in InDesign, Photoshop, Ai, FileMaker

Offline

 

#2 2012-02-09 01:39:59 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 10488
Website

Re: So what IS the "expected type" (specifically InDesign)

Hi,

POSIX file should be used as coercion

Applescript:


set imageURL to imageURL as POSIX file

If you often have to pass HFS paths, I recommend this method as a category of NSString

Applescript:


- (NSString *)HFSPathFromPOSIXPath
{
CFStringRef hfsPath = CFURLCopyFileSystemPath((CFURLRef)[NSURL fileURLWithPath:self], kCFURLHFSPathStyle);
   
   /* To support GC and non-GC, we need this contortion. */
   return [NSMakeCollectable(hfsPath) autorelease];
}


regards

Stefan

Offline

 

#3 2012-02-09 02:03:15 pm

SuperMacGuy
Member
From: Amish Country, Lancaster, PA
Registered: 2004-06-23
Posts: 416
Website

Re: So what IS the "expected type" (specifically InDesign)

Aaahhh yes. OK I remember reading that in Shane's book, doing sort of "backwards" coercion.
I had to do:

set imageURL to (imageURL as string) as POSIX file
Works now.
THANKS!

Last edited by SuperMacGuy (2012-02-09 02:05:19 pm)


Scripts for InDesign: http://chris.paveglio.com
ASOC & Cocoa, specializing in InDesign, Photoshop, Ai, FileMaker

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.045 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)