VectorGeek Posted March 6, 2010 Share Posted March 6, 2010 (edited) 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 March 6, 2010 by VectorGeek Quote Link to comment
JBenghiat Posted March 8, 2010 Share Posted March 8, 2010 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 Quote Link to comment
VectorGeek Posted March 8, 2010 Author Share Posted March 8, 2010 Thanks Josh. I will give that a try. VG Quote Link to comment
VectorGeek Posted March 12, 2010 Author Share Posted March 12, 2010 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 Quote Link to comment
JBenghiat Posted March 12, 2010 Share Posted March 12, 2010 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 Quote Link to comment
VectorGeek Posted March 12, 2010 Author Share Posted March 12, 2010 Josh, You are the man. Thanks for clearing up my script. It works perfectly now. BTW - what does "as alias" do? VG Quote Link to comment
JBenghiat Posted March 12, 2010 Share Posted March 12, 2010 alias gets something like a handle to the file (to use VS terms) as opposed to setting the variable to the path of the file as text. -Josh Quote Link to comment
Assembly Posted March 15, 2010 Share Posted March 15, 2010 New to applescript. I think I know what is going on- Q1) Can you give a bit of description of what this is doing?. Q2) Can you use apple script to say: Open Vectorworks Draw a line Print the drawing Close ?. Quote Link to comment
JBenghiat Posted March 17, 2010 Share Posted March 17, 2010 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 Quote Link to comment
Assembly Posted March 18, 2010 Share Posted March 18, 2010 Thanks.. ...so where do you start to learn applescript?. Quote Link to comment
xaei Posted June 11, 2010 Share Posted June 11, 2010 Josh- Just wanted to say thanks for explaining this. Am on VW 12.5.3 on OS 10.6, and have tried for hours to figure how to convert unicode in applescript back to ascii. This is amazing. AM Quote Link to comment
JBenghiat Posted June 12, 2010 Share Posted June 12, 2010 My pleasure. Unicode is one of those frontier standards that gets in the way of a lot of interoperability. I'm looking forward to the point where all my software is unicode savvy and I've been able to afford upgrading it all. Happy scripting. -Josh Quote Link to comment
_c_ Posted June 15, 2010 Share Posted June 15, 2010 Hi, there are on VectorLab two variants (pre Unicode and post Unicode) which you can use to create your own scripts: run script through AS the first is somewhat more extensive and perhaps inspires you, but you need to fix it for Unicode as the second one. orso Quote Link to comment
sdertsr6 Posted June 19, 2010 Share Posted June 19, 2010 Thank you for sharing guys. Quote Link to comment
Recommended Posts
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.