Ryota Posted June 29, 2017 Share Posted June 29, 2017 Hi, All. Can I ask how to call script in vwx file remote. I'd like to know if following ways work. OS is Windows7. -Pass script when VectorWorks is started from Command prompt. -Call from PowerShell. Thank you. Quote Link to comment
Patrick Winkler Posted June 29, 2017 Share Posted June 29, 2017 (edited) This can be done with the ActiveX interface. I have problems to get it work but you could give it a try since it only takes some minutes. First start VW as Admin once to register the ActiveX interface. Then you can create a JavaScript that uses the COM-Objects for Example. var fVWCore = new ActiveXObject("VectorWorks.Core"); var fVWScript = new ActiveXObject("VectorWorks.Script"); var fullFilePath = "C:\\Users\\????\\Desktop\\Sample VWX Files_2016\\"; var fileName = "sample_A.vwx"; fVWCore.OpenDocument(fullFilePath + fileName, false); fVWScript.DoScript("AlrtDialog('hello from the java script');"); Use the 'Windows Based Script Host ' to execute the script. Tell us if it works. regards Edited June 29, 2017 by Patrick Winkler 2 Quote Link to comment
Ryota Posted June 30, 2017 Author Share Posted June 30, 2017 Hi, Patrick Winkler. It Worked out using ActiveX. Thank you very match for your advice. May I ask additional question. Are there any available ActiveX Methods to pass PythonScript to VectorWorks. I tried DoScript of ActiveX but it didn't work. Quote Link to comment
Patrick Winkler Posted June 30, 2017 Share Posted June 30, 2017 Unfortunately it only supports VectorScripts. Quote Link to comment
Patrick Winkler Posted June 30, 2017 Share Posted June 30, 2017 (edited) Luckily there's a VectorScript function for calling python scripts: http://developer.vectorworks.net/index.php/VS:PythonExecute Simply wrap it up the Python code and call it with DoScript. vector_script = "PythonExecute( 'import vs; vs.AlrtDialog("This is a Pythonscript wrapped in a Vectorscript!" )');" Edited July 1, 2017 by Patrick Winkler Quote Link to comment
Ryota Posted July 3, 2017 Author Share Posted July 3, 2017 Hi Patrick Winkler. It Worked! Thank you very match! 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.