FranAJA Posted November 11, 2023 Share Posted November 11, 2023 (edited) 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 November 11, 2023 by FranAJA Quote Link to comment
JBenghiat Posted November 12, 2023 Share Posted November 12, 2023 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. Quote Link to comment
FranAJA Posted November 12, 2023 Author Share Posted November 12, 2023 (edited) 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) vs.Message(str(typeobj)) if typeobj == 3: vs.Message(str(typeobj)) return True else: break def pick_object(): h = None # Loop to start TrackObject while True: h = vs.TrackObject(check_obj_callback) # Added positional arguments if h is None: break Edited November 13, 2023 by FranAJA Quote Link to comment
Recommended Posts
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.