Jump to content

Python SOP with selectors


Peter Quint

Recommended Posts

Ive been experimenting with creating a python sop. I'm finding it hard to make it work with selectors - the advice in the docs is to use the onloaded method to add the selector, but this appears not to be being executed. The particular selector I want is an edge selector so it may be a fault in how im creating the selector.

A second question is whether selectors are usable only in python sops, or can they be used with more general digital assets?

Many thanks

Link to comment
Share on other sites

Unfortunately I've found trying to add selectors pretty pointless. They never work and have a number of internal bugs with them that makes this so. They are great in theory but fail in practical use until these bugs have been fixed. You are really better off writing a custom tool and making use of that than attempting to try these things out. Hopefully the bugs will be fixed eventually but I wouldn't count on it in the near future.

Also, when they do actually work properly they are usable for any asset, not just Python operators.

Link to comment
Share on other sites

A second question is whether selectors are usable only in python sops, or can they be used with more general digital assets?

Selectors work with all digital assets. They are used to prompt the user during the creation process. For example, those messages you see at the bottom prompting you to select geometry when creating a RDB Object. I think they are only used when the asset is created interactively, creating an asset using the Tab menu by-passes the selectors.

Link to comment
Share on other sites

Thanks for those anwers, really helpful. I feared it might be a bug and not just ignorance on my part. In a custom tool how do you go about gathering a selection of edges? I seem to run into problems with sceneview.selectgeo - it appears to work only in certain circumstances - not for example when you start off in a different selection mode (objects, points or whatever). Do you need explicitly to handle all the different initial modes?

Hopbin - the question about digital assets is because Id rather wrap some existing sops than write the whole thing in python. But I started with the python only approach.

Thanks

Peter

Link to comment
Share on other sites

You should also add a (python) shelf tool section. In the Edit Operator Type Properties dialog, go to Tools > Script. From there, you can click on the help icon there to get some info: http://www.sidefx.co...indows/edittool ... Basically, the method you want to use here is hou.SceneViewer.selectGeometry(). The method has many parameters, one of which is to specify what type of selection that you want for your shelf tool script.

Mind you, the modeling selection paradigm was changed in H9 to "select first, then invoke tool". So the workflow should be for the user to select their edges first, then invoke your shelf tool (or equivalently, the viewport TAB menu). Then selectGeometry() will take your geometry selection and convert it to the requested type. If you had *no* selected geometry, then selectGeometry() will prompt for one.

The H9 Tools tech paper also has some background info. For an even more "under the hood" tinkering, take a look at what goes on in $HFS/houdini/python2.6libs/soptoolutils.py

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

×
×
  • Create New...