Jump to content

Use VectorScript function / procedure in python

Recommended Posts


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


Share this post

Link to post

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.

  • Like 1

Share this post

Link to post

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!



Share this post

Link to post

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?

Share this post

Link to post

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

  • Like 2

Share this post

Link to post

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.

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.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...