Jump to content

comfy w/ vectorscript lost w/ python


Recommended Posts

Hey All,

Hopefully I am not the only one.

I have been writing VS for many years now, and can make it behave for me. This Python beast has bitten me now to the point of frustration. I am learning Python through tutorials, but want to know how all of this work with VW. I have installed python and Aptana Studios and i think i have linked it correctly, but am lost from here.

Is there someone out there who can create a step by step tutorial on how one can:

Create a python script

Save it

Link it

Debug it

Make it work in VW.

Make a template with all the necessary stuff to make new script.

I not asking for the world but a simple rectangle PIO would be wonderful.

Marionette has intrigued me to learn Python... I am I just need a little push on how to make this all swirl together

Thanks

Jeff

  • Like 1
Link to comment

Hi JMiller

I use Aptana Studio 3.

1. Set your project directory in Aptana

2. Add this location(in step 1) to the Environment Paths in vectorworks. (Under Scripts > Script Options) [You will have to search your workspace, because ours is totally different from the one thats shipped with VW]

3. Have a look at this post, for further info on Pythons equivalent of include methods and python caching etc.

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=220857#Post220857

Link to comment

I just want to mention that if you are familiar with VS, you can really jump into Python with just learning the syntax basics and remembering to add "vs." before every VW API call.

While using an IDE like Aptana or more complex coding structure like in Marionette can help you with coding, you can certainly start with using Python as a simple macro language.

As with VS, you can type code straight in a VW script editor window, just set the language to Python at the top of the window. The code can actually be a little simpler than VS, with no need for variable declaration, BEGIN/END wrappers, or terminating semicolons, etc. Also, don't forget that Python is case sensitive, and that procedures without arguments always need parentheses, eg. vs.FSActLayer()

The equivalent of {$INCLUDE} is import. Instead of providing a path to the file in the include directive, you add the path via Script Options, and it is available to all Python scripts. Also unlike the include directive, you are not inserting the included file's code at the point of the import call, but rather treating the file like an available class. That means everything you want to use in the external file that is not a constant must be wrapped in a class or function.

For a PIO, all parameters are available as members of vs. So for your rectangle PIO (assuming it's not event based), all you would need is this:

vs.Rect( 0, 0, vs.PWidth, vs.PLength )

HTH,

Josh

  • Like 1
Link to comment
Also, don't forget that Python is case sensitive

This is the killer for me.

PYTHON IS CASE SENSITIVE.

python is case sensitive

Python is Case Sensitive.

More time debugging this than anything else.

That and the fact that it is also indent sensitive. Where you would use a Begin/End in VS, you have to indent properly instead.

  • Like 1
Link to comment
Also, don't forget that Python is case sensitive

This is the killer for me.

PYTHON IS CASE SENSITIVE.

python is case sensitive

Python is Case Sensitive.

More time debugging this than anything else.

That and the fact that it is also indent sensitive. Where you would use a Begin/End in VS, you have to indent properly instead.

Link to comment
Also, don't forget that Python is case sensitive

This is the killer for me.

PYTHON IS CASE SENSITIVE.

python is case sensitive

Python is Case Sensitive.

More time debugging this than anything else.

That and the fact that it is also indent sensitive. Where you would use a Begin/End in VS, you have to indent properly instead.

Case Sensitivity is in a lot of programming languages, and I prefer it. Using a good IDE with code completion, there is no problem with it.

  • Like 1
Link to comment
  • 2 years later...

 

Quote

I just want to mention that if you are familiar with VS, you can really jump into Python with just learning the syntax basics and remembering to add "vs." before every VW API call.... etc.

 

@JBenghiat this is perhaps the most helpful single post I have seen on the topic of transitioning from VS to Python. Thank you! - could you please get this posted on the first page of the developer wiki : http://developer.vectorworks.net/index.php/Python - which is extremely terse for a beginner.

Edited by Benedick_Miller
Link to comment

@twk  the link you posted above no longer works - can you post an updated link?

 

the original link:

https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=220857#Post220857

 

links to a nice message: "The Vectorworks Community Board has been upgraded with a bunch of great new features and moved to this location. But don’t worry — ALL of the content has been migrated along with it, so anything that was on the old forum is still available for you to use and reference." but a search for #Post220857 just leads me back to this thread, which ain't much use!

Link to comment

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.

×
×
  • Create New...