Jump to content
Developer Wiki and Function Reference Links ×

AppleScript Fail - A Mystifying Conundrum


Recommended Posts

Hey all,

I have been using AppleScript (through QuicKeys) to fire some commands to version 11.5 (a friend's firm, not mine ;-).

My friend just changed over to VW 12.5.3 and now the AppleScripts fail. For example, if I create the most basic of scripts:

tell application "VectorWorks 12.5.3"

activate

DoScript "SysBeep;"

end tell

It fails with an error "VectorWorks 12.5.3 got an error: Some data was the wrong type."

Weirdly, it works OK from a Mac using Tiger (10.4.3), but fails on an Intel Mac running Snow Leopard (10.6.2).

I did see a post long ago from Dan Belfiori (an early scripter in VS, old-timers will know Dan) that claimed the problem was that the script text was being sent in Unicode so VW was not interpreting it correctly. I tried his suggestion of writing the text to a file then reading it back before executing the DoScript, but still no worky.

If anyone can solve this, they will receive inner peace, courtesy of the V-Geek.

Thanks dudes and dudettes!

V-G

Kick-ass new MacBook Pro 15"

Snow Leotard 10.6.2

VW 12.5.3, but I have newer versions

Intellivision 1.0

MacPaint on a 128K floppy

Edited by VectorGeek
Link to comment

You're correct that the problem is unicode. Mac 10.5 took AppleScript to unicode text, but VW didn't become unicode aware until 2009 (I believe, could be 2008).

If you're using VW 2008 (see above) and earlier and Mac OS 10.5 and later, then you can not pass text to DoScript in AppleScript. DoScript can take a file as an argument as well as text. Try something like:

tell application "VectorWorks"

set theScript to "path to a script text file" as alias

activate

DoScript (theScript)

end tell

-Josh

Link to comment

Josh,

I tried:

tell application "VectorWorks 12.5.3"

set theFileReference to open for access "Macintosh HD:Library:Application Support:MyTextFiles:testfile.txt"

set theFileContents to read theFileReference

close access theFileReference

activate

DoScript (theFileContents)

end tell

Still doesn't work. Any thoughts?

VG

Link to comment

VG,

You're making it a bit to complicated. You want to just pass the file itself to DoScript, not the contents:

tell application "VectorWorks 12.5.3"

set theFileReference to "Macintosh HD:Library:Application Support:MyTextFiles:testfile.txt" as alias

activate

DoScript (theFileReference)

end tell

-Josh

Link to comment
New to applescript.

Q1) Can you give a bit of description of what this is doing?.

The applescript switches to VW and runs the VectorScript code in testfile.txt

Q2) Can you use apple script to say:

Open Vectorworks

Draw a line

Print the drawing

Close

?.

VW's core applescript functionality is fairly limited, though it does support basic open and (I think) save commands. Applescript gets a huge boost, however, of being able to execute a Vectorscript. So in your case, AS would open and close, VS would draw the line and print.

-Josh

Link to comment
  • 2 months later...

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.

Guest
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...