Jump to content

Help with executing the tool command

Recommended Posts

Hello everybody, I have created a tool command and call it up via an icon button. I have the problem that I first have to click in the drawing area before I can work with the actual command. What did I do wrong?


c= 'Bemaßung'

import vs;
def CustTool():
    Result = vs.SetDefaultBeginningMarker(0, 15, 0.118103, 0.000000, 34, 0.050000, False); 
    Result = vs.SetDefaultEndMarker(0, 15, 0.118103, 0.000000, 34, 0.050000, False);
    Name = '';
    if vs.Name2Index(Name) > 0:


Dim_Std = {} #Dictionary of  Name and Index Number

while v !=1:
    vs.LinearDim((0,0), (0,0), 0, 0, 0, 0, 0)
    v=vs.GetObjectVariableInt(h,0) #if 1 the function switched to 1 because of an error
    if v !=1:
        Dim_Std[n] = v

vs.SetDimStd (Dim_Std.get(Choose_Standard));

Link to comment

Your script calls SetTool(), so when you click in the drawing, then the script runs and sets the tool. The second click is the first click of the actual tool.


Your options are either to run your command from a menu or tool palette, or rely on GetPt() etc and create the dimension via code rather than with it's tool. This is a limitation of VS-based tools.

Link to comment

No apologies necessary.


Vectorscript and Python are going to be the same in terms of functionality, though if you are new to scripting, using Python has the advantage of being a modern language with a lot of learning resources of anything outside the Vectorworks API, as opposed to Vectorcript, which is a proprietary version of PASCAL. Both, however, are run-time languages, so they depend on a singular trigger to run, in this case, clicking in the drawing.


The solution depends on what you are trying to make easier and who your audience is. If these are just to automate your workflow, just move your code form a tool to a menu, and you're basically done.


If you want something a little more user-oriented, you have to build your own tool. Your end result might be to run this command:


You can gather the end points with this:


or this:


Find an example of collecting points in Python here: https://developer.vectorworks.net/index.php/VS:GetPt

If you also want to set the distance from the object, you need to get a third point.


You can associate objects with a dimension with this command: https://developer.vectorworks.net/index.php/VS:AssociateLinearDimension


I can't recall if the tools will count the first click as the first point. You may need to use a TempTool to retrieve the first click:


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.

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