Jump to content

Nik

Member
  • Posts

    68
  • Joined

  • Last visited

Reputation

0 Neutral

Personal Information

  • Occupation
    LD
  • Location
    United States

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. @twk could you post an example of what you mean I'm wondering if the issue I'm having here is related:
  2. The weird thing is another PIO I use the logic is working fine, This is what I have done to try and figure out what is going on. this is python Script in the script editor.: import _Gizmo id, button = vs.vsoGetEventInfo() vs.AlrtDialog(f'Script Editor {id}') #normally I don't make this call here but in the _Gizmo.run after running the vs.GetCustomObjectInfo call _Gizmo.run(id, button) this is the python Script in "_Gizmo.run": vs.PushAttrs event.id, event.button = eventID, eventButton pioName, hPIO, recHand, wallHand = 0, 0, 0, 0 ok, pioName, hPIO, recHand, wallHand = vs.GetCustomObjectInfo(pioName, hPIO, recHand, wallHand) if ok: vs.AlrtDialog(f'Gizmo.run {event.id}') vs.PopAttrs When I exit the VW SciptEditor I get the following alerts: Script Editor 5 Script Editor 3 Gizmo.run 3 So it appears the onInit event is not "finishing"
  3. I have an event-based PIO Linear Object that doesn't seem to be firing the OnInit event. I have an AlrtDialog that fires immediately after vsoGetEventInfo function but I never get an event ID of 5. Specifically I don't get it the first time I use the tool after opening VW2023. Any thoughts?
  4. How does one get a handle to the First Selected Object that is not necessarily on the Active Layer? In my instance I am trying to step through all the selected items that might or might not be on the Active Layer since View->Layer Options->Show/Snap/Modify Others is selected. If I use vs.FSActiveLayer() it only will cycle through selected items on the active layer.
  5. When modifying my workspace I can't seem to add dividing lines to a menu. I can select the line object from the left column and drag it over but it never gives me the line-with-circle to insert it. I'm using the latest service pack for 2022. No issues doing this in previous versions.
  6. Can't seem to get import to work in python based scripts: this keeps generating the ModuleNotFoundError. the "_CableLayoutToolv2021A.py" file is in my Workgroup Plug Ins folder. I've included the Workgroup Plug Ins folder in the Python Script Environment Paths VW is seeing the VSO file that's in the Workgroup Plug Ins folder, just won't import the module thats in the same folder.
  7. this is the bit of code Josh was referring to prevent VW from caching. I've also found that python in VW is very sensitive to tabs versus spaces. I have my external editor set to insert 4 spaces when I tab. If I copy and paste a snippet from VW to my external editor it copies it as tabs and I have to run a utility that converts tabs to spaces. import yourExternalFile import imp imp.reload(yourExternalFile) #reloads the external file so VW doesn't use a cached version vs.SetPref(412, True) #Turns off include caching
  8. Nik

    vs.GetPt()

    In python GetPt and, I assume, GetPtL (since the reference says it works similarly) don't return anything. You create a callback function and can use the point inside the callback function. You can't set a global variable equal to the point, since the main script keeps running while the callback waits for the user to select a point. At this point, I've tossed vs.GetPtL out the window, but it would be helpful if someone on the Vectorworks team could properly document the function's parameters, and how many and what parameters are needed in the callback function.
  9. Nik

    vs.GetPt()

    So I have had no sucess in trying to get vs.GetPtL to work. My guess is that it should look something like this: def cb(pt1): def cb2(pt2): print('point 1: ',pt1,' point2: ', pt2) print('point 1 in cb: ', pt1) vs.GetPtL(cb2) #<-- throws tuple index out of range #vs.GetPtL(pt1, cb2) #<-- throws invalid number of parameters to callback function #vs.GetPtL(cb2, pt1) #<-- throws invalid number of parameters to callback function #pt2 = vs.GetPtL(pt1) #<-- this is what's in the vs.py file as an example, #but it too throws invalid number of parameters to callback function vs.GetPt(cb) So I gave up and used GetRect which works (the "rubber band' is a line and not a rect) : def CB(pt0, pt1): print('-CB-') print('pt0: ', pt0) print('pt1: ', pt1) vs.GetRect(CB)
  10. okay! I learned somethings... respond2SurfaceEdit should actually be called OnInit the vsoAddParamWidget command should be in OnInit and to actually be able to add widgets and adjust their visibility/enabled state you need to include the following at the beginning of the OnInit: ok = vs.SetObjPropVS(8, True) #kObjXPropHasUIOverride} ok = vs.SetObjPropVS(12, True) #kObjXHasCustomWidgetVisibilities}
  11. Trying get a handle on using event handling for PIOs.(Pun fully intended) Mostly look to build my parameters programmatically rather than using the Plug In Manager. Here's a little script I've added to a Point object. My understanding is that I should build my parameter widgets during the respond2Widget prep event, but that event never seems to get triggered. When I select the object from my Tool Palette it triggers a respond2SurfaceEdit, then a resetEvent. When I click in the drawing to place it I get respond2SurfaceEdit, resetEvent, respond2SurfaceEdit, resetEvent. Am I missing something? If so what am I missing? Where can I find some documentation on this? code below: def eventHandler(): def resetEvent(): pioName, hPIO, recHand, wallHand = 0, 0, 0, 0 ok, pioName, hPIO, recHand, wallHand = vs.GetCustomObjectInfo() if ok: vs.Rect(0,0,1,1) def parametricPref(): None def respond2SurfaceEdit(): None def onSpecialEdit(): None def onReshape(): None def onButtonPress(): None def respond2WidgetPrep(): vs.vsoAddParamWidget(9, 'testing', 'A Test') vs.vsoSetEventResult(-8) def onParamValChange(): None def triggerEvent(argument): eventSwitcher = { 3 : resetEvent, 4 : parametricPref, 5 : respond2SurfaceEdit, 7 : onSpecialEdit, 9 : onReshape, 35 : onButtonPress, 41 : respond2WidgetPrep, 44 : onParamValChange, } # Get the function from switcher dictionary func = eventSwitcher.get(argument, lambda: "nothing") vs.AlrtDialog(func.__name__) # Execute the function return func() theEvent, theButton = vs.vsoGetEventInfo() triggerEvent(theEvent) vs.PushAttrs eventHandler() vs.PopAttrs
  12. should have been more clear... need to check if the symbol exists in the drawing symbol library. vs.GetObject works to check if a symbol has been inserted in a drawing. try/except does work for other types of errors. but maybe not for VW thrown errors? The following bit of code works as expected try: x = 9/0 except: vs.AlrtDialog('This is division by zero!')
×
×
  • Create New...