How to use shelf tools in custom tools?

   3481   3   0
User Avatar
Member
15 posts
Joined: Sept. 2010
Offline
Hi,

I'd like to call the bonesfromcurve tool in a custom tool I'm attempting to write. I have two questions:

1) Where does the bonesfromcurve command live? Following the calls made in the Script window after running Edit tool I got this far:

/rel/third_party/houdini/11.0.775_64/houdini/toolbar/ObjectStateTools.shelf
Which calls:
import objecttoolutils
objecttoolutils.customStateTool(kwargs, ‘bonesfromcurve’)

objecttoolutils module is located in:
/rel/third_party/houdini/11.0.775_64/houdini/python2.6libs/objecttoolutils.py

Which Calls:
toolutils.genericTool(kwargs, ‘bonesfromcurve’)

toolutils module is located in:
/rel/third_party/houdini/11.0.775_64/houdini/python2.6libs/toolutils.py

From there I'm stumped, does anybody know where bonesfromcurve actually lives or how to find it?

2) A path of lesser resistance may be to call it directly from my own tool, but I don't know how. Any suggestions on this one?

Thanks,
Chris
User Avatar
Staff
1449 posts
Joined: July 2005
Offline
objecttoolutils.customStateTool() calls
toolutils.genericStateTool(), which calls
pane.setCurrentState()

It is the pane.setCurrentState('bonesfromcurve') that makes the viewport enter the Bones From Curve state (the name of the state is shown in the viewport toolbar).

Probably, the easiest way for you is to call toolutils.genericStateTool() in your own shelf tool.
User Avatar
Member
15 posts
Joined: Sept. 2010
Offline
Hi Rafal,

Thanks for the tip. I'm trying to build a tool that auto-rigs hair curves imported from disk. The bonesfromcurve wants to work on objects not primitives; can I get it to work on primitives?

Also I'd like to feed the Chain Name and Number of bones attributes from my script but I can't find any documentation on the bonesfromcurves command I can only find documentation on the shelf tool. Is the script the command runs available for inspection?

Thanks,
Chris
User Avatar
Staff
1449 posts
Joined: July 2005
Offline
The bonesfromcurve wants to work on objects not primitives; can I get it to work on primitives?
Bones are objects and not geometry, so the viewport tool works at the object level. The main reason, however, is that the Bones From Curve can assign kinematics solver to the bones, and the solver requires an object and not a geometry (to get its position, orientation, etc in scene space).

You can still try creating bone chains for each hair geometry, but you will need to put each of them in own object (with fetch sop?). Or your tool could keep using one object with fetch sop, reconfigure the fetch sop to grab one hair and create bones for it, and repeat that. Note, though, that you will be able to assign follow-curve kinematic only when you have one object for each hair geometry, and won't be able to do that if you reuse one temporary object for bone generation.

However, the main obstacle to your shelf tool may be that the Bones From Curve require the viewer to function correctly. I guess your script could try selecting the curve object then invoking bones-from-curve state to generate the bones, then selecting another curve object, and generating bones for that, etc.

Unfortunately, I don't think the Bones From Curve state parameters (ie, number of bones) can be controlled programatically from your python script. The viewer state tools were meant as an interactive UI facility, rather than for scripting.
  • Quick Links