Jump to content

Calling temporary a tool Vectorscript inside a Python Script


Recommended Posts

The issues with the user interactive methods are well known and reported several time in the forum: 


However, until Vectorworks decide to fix this (I hope in an update soon (please vectorworks, come on!)),
I need to find a workaround otherwise 99.9% of the script that are useful for my job can not be created.

I would like to select interactively objects, ideally without selecting by criteria or clicking point randomly in the screen without any reference or highlighting.
These scripts will be used daily, by normal user or not specialist of VW, so should be user-friendly.

I was wondering if TrackObject tool can be defined externally into a Vectorscript (which seem the only way it works) and then call it into a python script tool just for the purpose of selection/highlighting/handling.
I found some topics talking about RunTempTool, however there is not any example of its use in a python environment and seems really criptic but i would like also to investigate this.

If someone has already used this method or created a way to run VS bits into python code, his help will be really appreciated. 

Edited by FranAJA
Link to comment

You might have to be more specific about which issues you’re referring to. 

Python isn’t able to pause and wait for input the way VW does — this is due to how the language works, and you have to construct your script with callbacks of you want to handle user interaction. 

This can’t be changed by running vs within python: you still have the same issue with Python being non-blocking. 

Both VS and python tool scripts don’t execute until the first click, and there’s no way around that. Track object and temp tool work best as menus. 

There’s also a bug that appeared in 2023 that would cause temp tool to crash. I’m not sure if that has been fixed yet — but it’s a regression, so it should be high on the list. 

Link to comment

Thank you Josh, 

The issue is that is basically impossible (or is useless) to use TrackObject with python without interrupting the method. 
I would like to click down to handling the object to pick data from it, but this will interrupt the call back.
I quite like the red highlighting behaviour, like when I apply a data tag or I pick walls for space boundary, for example (image: walls picked for space boundary).
Object remain red highlighted and i can highlight multiple objects as well but i think i am overdemanding.


I have tried to mix a loop with track object with a loop of mouse down (method pick_object activated by pressing a push button in PIO object point, so the PIO object is already in the design layer.)
which works until i press down and i go on the obejct just with the arrow without clicking.
I would like to find a solution for the handling of the highlighted object, but I am very far from it i think.

I am still investigating all the function  and how python works in VW, probably I am completely on the wrong line. 

# The loop while, highlights type 3 (Rect) objects until the mouse is up.
# When the mouse is down i still need to understand how to handling the object if type = 3 vs.SelectedH(h)
def check_obj_callback(h, px, py):
    # if mousedown(px, py) is True:
    click, pt = vs.MouseDown()
    while not click:
        # h = vs.vstGetPickObject(pt[0], pt[1])
        if h != None:
            typeobj = vs.GetTypeN(h)
            if typeobj == 3:
                return True

def pick_object():
    h = None
    # Loop to start TrackObject
    while True:
        h = vs.TrackObject(check_obj_callback)  # Added positional arguments
        if h is None:


Edited by FranAJA
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...