Jump to content

Calling DoScript with Applescript on VW2011/MacOS X 10.6


Recommended Posts

I am having trouble sending an Applescript to VW2011 (SP2) under MacOS X 10.6

With VW2009 on the same machine, I use this Applescript to send the contents of my editor?s front window to Vectorworks:

-- getplaintext subroutine called from within the Tell using 'of me'

on getplaintext(fromUnicodeString)

set styledText to fromUnicodeString as string

set styledRecord to styledText as record

return ?class ktxt? of styledRecord -- Ensure Western (Mac OS Roman) encoding

end getplaintext

tell application "SubEthaEdit"


-- Get the script text out of SEE as a string.

set theScript to the plain text of document 1 as string

-- Convert from Unicode

set theScript to getplaintext(theScript) of me

tell application "Vectorworks 2009"


-- Execute the script in VW

ignoring application responses

DoScript theScript

end ignoring

end tell

end tell

This does not function with VW2011 as the AS compiler returns ?Expected end of line but found identifier.?

Changing the line to DoScript(theScript) gives a clean compilation but it does not work with VW2011 (other than bringing VW to the front) and no errors are reported that I can find.

I see elsewhere that using a file reference in a script has been used but I cannot make this work with VW2011 either:

set theFileReference to "My HD:Users:Me:Desktop:VScript.txt" as alias

tell application "Vectorworks 2011"


-- Execute the script in VW


end tell

An error is returned by the system: ?error "Vectorworks 2011 got an error: Can?t continue DoScript." number -1708?

This error is not an Applescript or OS error code that I can find so was probably returned from Vectorworks but I cannot find any trace of this error code in the documentation I have searched.

I have tried different file encodings for the script file without success.

If I open the same file with the Run VectorScript command, it executes as expected.

So what is the official way to address DoScript in VW2011 under MacOS X 10.6? I can find no trace of any recent documentation on the subject.

Using a file reference would be by far my least favourite option as it means creating an intermediate file on each occasion to a fixed location as text first, so the old way would be much easier if it is still possible.

Many thanks,


Link to comment


I think there might be an AS dictionary bug introduced in SP2. Opening my Run 2011 script for BBEdit, it now looks like:

tell application "BBEdit"
set theScript to contents of front window
end tell

tell application "Vectorworks 2011"
?event miscdosc? (theScript)
end tell

If I replace ?event miscdosc? with DoScript, DoScript is seen as a variable and not a keyword. If I leave as is, the script works. I'm filing this as a bug.

That said, VW 2011 is Unicode aware, so both cleaning the text or passing a file to DoScript are no longer necessary.


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...