Jump to content
Nik

PIO Event Handler

Recommended Posts

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

Share this post


Link to post

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}

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.

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