Jump to content
Developer Wiki and Function Reference Links ×

First steps with Python


DomC

Recommended Posts

Hello

I wanted to port some of my Document-Based Pascal Scripts to Python. Not because it ist necessary, just to learn something.

I tried just to build a Python example with some commands from the Vectorworks Namespace.

def Test():
   Text = 'Hello Vectorworks.'
   vs.AlrtDialog( Text+' This should work, or not?')
   vs.moveto(0,0)
   vs.Lineto(0,500)
Test()

The "AlrtDialog" seems to work. vs.moveto and vs.lineto do not want

Many thanks for some ideas!

Dom

Error Message:

Traceback (most recent call last):

File "", line 7, in

File "", line 5, in in Test

AttributeError: 'module' object has no attribute 'moveto'

Edited by DomC
Link to comment
Guest Jim Kelly

It's a case sensitivity thing - notice that you have "moveto" as the method name and not "MoveTo" and "Lineto" and not "LineTo".

Just ensure the case matches up here:

http://developer.vectorworks.net/index.php/VS:Function_Reference

You can also use the information at the bottom of here:

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

to use an IDE when developing that will autocomplete for you and/or do linting to tell you if a method doesn't exist.

Link to comment

Wow, a stupid alpha error.

(vectorscript is not case-sensitive)

Thank you so much!

Just to complete, the running code:

import vs

def Test():
Text = 'Hello Vectorworks.'
vs.AlrtDialog( Text+' This should work, or not?')
vs.MoveTo(0,0)
vs.LineTo(0,500)
Test()

Link to comment
Guest Jim Kelly

Oh wow, actually that brings me back now that you mention it, because Pascal was my second programming language, and I guess now that you mention it, yes it wasn't case sensitive. Blast from the past. :)

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