zglynn Posted February 6, 2011 Share Posted February 6, 2011 (edited) Hey everyone, I'm trying to return a sop that the user selects. I can do it just fine with: hou.selectedNodes() Only problem is I want to tell the using with some kind of prompt to select the sop that he or she wants and press ok. But when I try to use the: hou.ui.displayMessage() It locks out houdini's ui and you can't select anything while the dialog prompt is up. With some digging I figured out how to return a node at object level with: import toolutils import hou scene_viewer = toolutils.sceneViewer() selection = scene_viewer.selectObjects(prompt = toolutils.selectionPrompt(hou.objNodeTypeCategory())) print selection And this works great, but when I try do to the same thing for a sop node... import toolutils import hou scene_viewer = toolutils.sceneViewer() selection = scene_viewer.selectGeometry(prompt = toolutils.selectionPrompt(hou.sopNodeTypeCategory())) print selection It returns nothing. It just prints blank space. I would really appreciate any help. Thanks, Zach Edited February 6, 2011 by zglynn Quote Link to comment Share on other sites More sharing options...
kubabuk Posted February 6, 2011 Share Posted February 6, 2011 import toolutils import soptoolutils activepane = toolutils.activePane(kwargs) if activepane.type() != hou.paneTabType.SceneViewer: raise hou.Error("This tool cannot run in the current pane") scene_viewer = toolutils.sceneViewer() nodetypename = "delete" # Obtain a geometry selection geo_types = (hou.geometryType.Primitives, ) selection = scene_viewer.selectGeometry( "Select the primitives to extract and press Enter to complete", geometry_types = geo_types, allow_obj_sel = False) print "This is what you selected: ",selection selectionList = str(selection).split(' ') selectionList=selectionList[:-1] # remove lase element which is '' when selectin all primitives in the SOP it returns only ' ' --- PROBLEM - if you want to change the order of all the primitives select one by one excepth the last element print selectionList for sop in selection.nodes(): sop_path = sop.path() print sop_path ### Last line scene_viewer.enterCurrentNodeState() Quote Link to comment Share on other sites More sharing options...
zglynn Posted February 7, 2011 Author Share Posted February 7, 2011 Thanks a lot Kuba. This looks great! I'll give it a shot and let you know how it goes. Zach 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.