Christoph_H Posted December 17, 2019 Share Posted December 17, 2019 Hi, how to get viewport handles for created points with addpoint() ? Quote Link to comment Share on other sites More sharing options...
anim Posted December 18, 2019 Share Posted December 18, 2019 best would be to wrap it into HDA, then you can create python state and bind handles dynamically that way https://www.sidefx.com/docs/houdini/hom/state_handles.html Quote Link to comment Share on other sites More sharing options...
Christoph_H Posted December 18, 2019 Author Share Posted December 18, 2019 thanks. Hi, I have try it. But it's not perfect or flexible. Maybe you can help a little bit? I have problems to use it with multiparm block lists. handles_pts.hdanc Quote Link to comment Share on other sites More sharing options...
anim Posted December 18, 2019 Share Posted December 18, 2019 you are creating static handles, which are only limited to hardcoded amount for the example of dynamic handles created using python viewport states as mentioned above you can have a look at Rbd Constraints From Rules or PointWeld SOPs Quote Link to comment Share on other sites More sharing options...
Christoph_H Posted December 21, 2019 Author Share Posted December 21, 2019 Hi, I have to ask again for help. I have recently started with python and therefore still have Problems. This script is placed in the | type proberties | interactive | viewer state |: 1. By adding newer points the effect changes only if I press apply at viewer state 2. Somehow the program did not accept the relative path to the parameter. How does that work? 3. and I haven't been able to create new handles yet I would be interested in how a clean structure of such a script would be written help would be great. many thanks. import hou import viewerstate.utils as su picker_folder = str(hou.evalParm('/obj/geo1/picker/folder0')) #Somehow the program did not accept the relative path to the parameter. How does that work? pickerx = "picker"+picker_folder+"x" pickery = "picker"+picker_folder+"y" pickerz = "picker"+picker_folder+"z" print(pickerx,pickery,pickerz) #print(picker_folder) class State(object): def __init__(self, state_name, scene_viewer): self.state_name = state_name self.scene_viewer = scene_viewer self.translate_handle = hou.Handle(self.scene_viewer, "Translate") def onEnter(self, kwargs): self.translate_handle.show(True) def onHandleToState(self, kwargs): """ Used with bound dynamic handles to implement the state action when a handle is modified. """ handle = kwargs["handle"] parms = kwargs["parms"] mod_parms = kwargs["mod_parms"] prev_parms = kwargs["prev_parms"] ui_event = kwargs["ui_event"] self.log(parms) def onStateToHandle(self, kwargs): """ Used with bound dynamic handles to implement the handle action when a state node parm is modified. """ handle = kwargs["handle"] parms = kwargs["parms"] node = kwargs["node"] def createViewerStateTemplate(): """ Mandatory entry point to create and return the viewer state template to register. """ state_typename = kwargs["type"].definition().sections()["DefaultState"].contents() state_label = "picker" state_cat = hou.sopNodeTypeCategory() template = hou.ViewerStateTemplate(state_typename, state_label, state_cat) template.bindFactory(State) template.bindIcon(kwargs["type"].icon()) # bind a static handle to node parameters. template.bindHandleStatic( "translate", "Translate", [ (pickerx, "tx"), (pickery, "ty"), (pickerz, "tz") ]) return template Quote Link to comment Share on other sites More sharing options...
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.