michaelk Posted September 28, 2013 Share Posted September 28, 2013 Is there something I need to install before running a Python script? I'm unable to get any Python script to run, even "Hello, World" I've tried translating some existing one line scripts with no success. For example, this is a simple one-liner I often use from VS: SetPref(44,FALSE); What would that look like in Python? Thanks! mk Quote Link to comment
michaelk Posted September 28, 2013 Author Share Posted September 28, 2013 Interesting.... Can someone check this? 1. In a VW script editor window, select Python as the language and type in vs.AlrtDialog('Hello') 2. Run the script. Works Great. 3. Edit the script. Add a space in the wrong place: vs.Alrt Dialog('Hello') 4. Run the script. Get the error message, click "View Error Output..." The Script Errors dialog box says: File "", line 1 vs.Alrt Dialog('Hello') ^ SyntaxError: invalid syntax 5. Click on Edit Script... Remove the space. Click OK. 6. Run the script again. I get the same error. If I edit the script by right clicking in the RB and choosing Edit... the edit "sticks". If I choose edit Edit Script... from the Script Errors dialog the edit doesn't "stick". mk Quote Link to comment
michaelk Posted September 28, 2013 Author Share Posted September 28, 2013 The lack of indentation in this forum is going to be a problem for python scripts.... Quote Link to comment
michaelk Posted September 28, 2013 Author Share Posted September 28, 2013 Now that I (maybe) understand why I was unable to edit a script to make it run... vs.SetPref(44, False) works as a python script. At first I was trying to use Message instead of AlrtDialog vs.Message('Hello') returns the error: Traceback (most recent call last): File"", line 1, in AttributeError: 'module' object has no attribute 'Message' Any ideas? thanks MK Quote Link to comment
Jonathan Pickup Posted September 29, 2013 Share Posted September 29, 2013 SetPref(44,FALSE); try: vs.SetPref(1,True) Quote Link to comment
michaelk Posted September 29, 2013 Author Share Posted September 29, 2013 Hi Jonathan I got SetPref to work fine in Python. My problem was what I suspect is an edit bug in the VS editor. This whole thread started because I couldn't make vs.Message() work (still can't) and I ran in to the editor bug. Any ideas about vs.Message? mk Quote Link to comment
Jonathan Pickup Posted September 29, 2013 Share Posted September 29, 2013 i cant make vs.Message() work Quote Link to comment
MullinRJ Posted September 29, 2013 Share Posted September 29, 2013 i cant make vs.Message() work Neither can I. Bug submitted. Quote Link to comment
michaelk Posted September 29, 2013 Author Share Posted September 29, 2013 I submitted also. Is anyone else seeing the Edit bug? Quote Link to comment
MullinRJ Posted September 30, 2013 Share Posted September 30, 2013 Yes. I did, but only once. I made some other changes and saved them, then pasted the vs.AlrtDialog() statement back and it worked. After that I couldn't make it fail, even in a new file. Perhaps restarting VW might help it fail again. It's an intermittent bug, at best. Did you file? Raymond Quote Link to comment
michaelk Posted September 30, 2013 Author Share Posted September 30, 2013 Just tried it again after a restart. Same thing. Changes made after a syntax error using the Edit Script... button in the Script Errors dialog box don't work. Bug filed. Quote Link to comment
Ilay Posted September 30, 2013 Share Posted September 30, 2013 (edited) Hello Michael Python works for me(win xp sp3 and 8), i download PythonSample_Menu2. I test it(got errors), when i looked at code: 1. i put ui* dir to site-packages dir, because natively there is not such name of class in VW pyAPI 2. modify main(.py) fuction - this, adding execute() to end * - dir from sample - PythonSample_Menu2\ui\ Edited September 30, 2013 by Ilay Quote Link to comment
Ilay Posted September 30, 2013 Share Posted September 30, 2013 vs.Message('Hello') returns the error: Traceback (most recent call last): File"", line 1, in AttributeError: 'module' object has no attribute 'Message' Any ideas? Does it has reference to palette gui?, like c4d status Quote Link to comment
Vectorworks, Inc Employee Vlado Posted October 2, 2013 Vectorworks, Inc Employee Share Posted October 2, 2013 Hey guys, it seems the vs.Message was not added to python. This omission be fixed in SP2. Quote Link to comment
Vectorworks, Inc Employee Vlado Posted October 2, 2013 Vectorworks, Inc Employee Share Posted October 2, 2013 Hi Ilay, you should not copy anything to 'site-packages' from the sample. Unzip the sample in your user's plug-ins folder and that should be all. when a vsm, vsm, or vst runs, VW adds that folder to the python search path. So, when the scripts does 'import import ui.dlgHandler' the first thing python would do is to look for a folder 'ui' next to the vsm. Quote Link to comment
Ilay Posted October 3, 2013 Share Posted October 3, 2013 Hello Vladislav Thanks a'lot Anyway can we use additional math/graphical libs as Numpy an etc.? honestly i don't like such scheme*: when a vsm, vsm, or vst runs, VW adds that folder to the python search path. So, when the scripts does 'import import ui.dlgHandler' the first thing python would do is to look for a folder 'ui' next to the vsm. Currently pyAPI has dependence from vwvs * - hmm, that why i made several test project, and they did not work properly. Quote Link to comment
Vectorworks, Inc Employee Vlado Posted October 3, 2013 Vectorworks, Inc Employee Share Posted October 3, 2013 (edited) Anyway can we use additional math/graphical libs as Numpy an etc.? Yes, you should be able to. Those you should install in the side packages. Edited October 3, 2013 by Vladislav Stanev Quote Link to comment
michaelk Posted October 9, 2013 Author Share Posted October 9, 2013 i cant make vs.Message() work Neither can I. Bug submitted. Has anyone else had the same problem with STRING = vs.GetFldName(h, index) mk 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.