Paolo Posted September 17, 2020 Share Posted September 17, 2020 Hello, Is it possible to use a VectorScript function in a python script? I have many procedures and functions (in an include .vss file) written in VectorScript and I would avoid to rewrite them all… There should be the vs.CallDynVSFunction for this, but how to use it? Someone has tried it? Are there examples? Thank you in advance Paolo Quote Link to comment
JBenghiat Posted September 17, 2020 Share Posted September 17, 2020 This function is for running commands that are defined by SDK plug-ins (as opposed to core VS functions). Python variants get created automatically now, so this command isn't really necessary. You can call python from vs, but not the other way around. 1 Quote Link to comment
Peter Vandewalle Posted September 17, 2020 Share Posted September 17, 2020 I think rewriting is the only way to go. Python is slightly faster in execution than Vectorscript. 1 Quote Link to comment
Paolo Posted September 17, 2020 Author Share Posted September 17, 2020 Thank you all. I think I am going to rewrite this python plugin in Vectorscript since all functions and procedures I need are in Vs. I know I should start to refactor my (Mouldings) plugins in python, but it’s a big work! Paolo Quote Link to comment
_c_ Posted October 8, 2020 Share Posted October 8, 2020 Paolo, you do know that there is no encryption afterwards, though? As far as I know, python plug-ins are more or less open to read with any text editor. There are a number of threads in this sense. Or is there a workaround? Quote Link to comment
tbexon Posted October 8, 2020 Share Posted October 8, 2020 There is a work around. Rather than writing the script within the Plug in script itself write it in a YourScriptName.py file located in the same directory as the .vsm file within you're plug in folder. Then, within the Plug In Script, you just need to import the other script: import YourScriptName The .py File is still easily read so the next step, when you're ready to encrypt and distribute said plugin, is to swap the .py for the compiled python file( .pyc), which is located within the "__pycache__" folder of whatever directory the .py file is stored in. (for more info on .pyc files check out this) As long as you put the .pyc in the exact same location as where the .py was, it should function exactly the same. This still isn't perfect. Compiled files can still be de compiled but this requires a much higher level of knowledge than simply opening in a text editor! For more general info on encrypting python plug ins check out this thread 2 Quote Link to comment
_c_ Posted October 8, 2020 Share Posted October 8, 2020 Great to know, thank you so much, @tbexon! 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.