Jump to content

vs.vstGetPt2D() not working

Recommended Posts

Hello all,


After having learned some basic Python, I'm trying to get started with Python in Vectorworks.

As an exercise I'm trying to create a basic version of the existing 'Move by Points'-Tool:

Get two points (pt1 and pt2) clicked by the user and then move a previously selected object by (x2-x1, y2-y1) but I'm having problems getting the user input.


As I understood from previous posts, vs.GetPt() only works with commands but not with tools.

Instead, the function to use would be: vs.vstGetPt2D() http://developer.vectorworks.net/index.php/VS:vstGetPt2D

The script of my Tool-Plugin refers to _main.py as follows:

import _main

_main.py looks like this:

import vs
def execute():
    pt = vs.vstGetPt2D()

After starting the tool, no matter where I click, I get (1e+100, 1e+100) as a result.

Also I don't quite understand what the required parameters (inPtIndex, result) should be set to?

In the example above I just left them away which of course causes an Error (Invalid number of parameters...) but still prints the Message.

Setting them to something arbitrary like vs.vstGetPt2D(1, True) doesn't result in an Error but still prints the wrong coordinates.

Is the problem related to the parameters or what is it that I'm not getting?


Thanks in advance!



Share this post

Link to post

Vs.GetPt() would be the call to use, or because you need two clicks, GetPtL(). The vst functions work with RunTempTool and TrackObject, and require you to structure your code as an event handler. 


Note that all script based tools start execution on the first click. This can be an issue if you are doing selection processing like with TrackObject, but because you want the first click the user makes to set the start of your move offset, having that click start the script shouldn’t be an issue. 


Share this post

Link to post

Thanks for your reply.

As already mentioned, I can't get vs.GetPt() to work in a Plugin-Tool.

The following code works perfectly fine as a Script or Plugin-Command but won't work when used in a Tool (i.e. nothing happens, no Message, no Error,...)

import vs
def callback(pt):


Share this post

Link to post

There seems to be a delay for when the callback runs.  You can write your own handler fairly simply


import vs

def GetPt():
	click = False
	while not(click):
		click, pt = vs.MouseDown()
pt = vs.GetMouse()	


Share this post

Link to post

I've been experimenting around with vs.MouseDown(), too.

It kind of works but it's of no practical use since snapping won't work anymore which makes precise drawing / moving impossible.


It seems like simply getting a click from the user is not as obvious as I thought it'd be..

I'll probably stick to writing plug-ins as commands then.


Thanks for your help!



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