Jump to content

Recommended Posts

I'm trying to explore scripted Python plugins, but I'm having trouble finding any basic information on how scripts function within a plugin and interact with specified parameters.

For example, I've created a tool plugin and put in what I thought was the most basic script:

 

vs.Message('Test Tool')

 

When I click on the tool I get an error message: Identifier Not Declared.

What does this mean? I tried declaring a function and then running the function, but I get the same error, always on the first line; even /import vs/ will give me this error. Just looking for a place to begin experimenting.

Share this post


Link to post

I am a Vectorscript guy more than a Pythonscript person, but take a look at the information on the developer pages

 

https://developer.vectorworks.net/index.php/Python

 

I would also recommend that you try and learn of some simple scripts first before you jump into PIOs.   Make sure you can compile and make a script run just using the script editor from the Resource Manager. Once you get that figured out it will be much easier to move into the PIO world.

 

Once you have a simple script in a Script Palette, if you have the palette open, you can Option (Alt) click on the script and it will open the editor so you can make changes after than having to navigate to the PIO editor.

 

Long term if you want to write PIOs you will want to learn how to use an external editor and include files and how to force scripts to compile every time they run.

 

Welcome to the club!

Share this post


Link to post

Check in the script editor(top right) that PPython is the selected Language I supsect you have VectorScript selected.

 

regards,

Patrick

Share this post


Link to post

I have some simple scripts working already, so now I'd like to make those scripts into plugin objects or tools; I've been using Python for 2 or 3 years mostly within TouchDesigner and have written some pretty robust code, so I'm very comfortable with that side of things.

 

I think I could move one step forward if I just understood what this error is trying to tell me. Python is the selected language.

Share this post


Link to post

@sully8391 ,

In the Script Editor window, when I have "Language: VectorScript" selected I get this error:

 

Line #1:  vs.Message('Test Tool')

          |
       { Error: Identifier not declared. }
 

When I have "Language: Python Script" selected, the script runs as expected. This is in a Script Palette script, and in a Tool Plug-In.

 

Also, check in a word processor for any hidden characters in your one-line script, or select all, delete, and retype the line again. One hidden character will crater the simplest of code.

 

Good luck,

Raymond

Share this post


Link to post

@MullinRJ Weird, I just created a new tool, and it works fine. The first one keeps giving me this error no matter what. I did have it set to Vector Script initially, but fixed that after the first time I had the error, so I wonder if that has anything to do with it. No hidden characters. I'll have to see if a restart corrects it.

Share this post


Link to post

Restarting Vectorworks solved the problem, seems like even though I changed the language to Python, Vectorworks was still interpreting it as VectorScript.

Share this post


Link to post

Ain't programming fun? Glad you got it working.

 

Raymond

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.

Guest
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...