Python selectObject() question

   5606   5   0
User Avatar
Member
512 posts
Joined: July 2009
Offline
Hi guys,

I finally started learning Python and after working through some basics I began with the HOM Cookbook “object_xform” lesson, where you create a shelftool that unparents selected nodes and keeps it's previous worldTransform value.

the code is as following:

—————————-
import toolutils

def unparenter(myvar):
xform = myvar.worldTransform()
myvar.setFirstInput(None)
myvar.setWorldTransform(xform)
viewer = toolutils.sceneViewer()
myvar = viewer.selectObjects(quick_select=True)

unparenter(myvar)
——————————————

all very clear to me, except that I don't know where is coming from.
Means I don't know the correct syntax for selectObjects().
How can I find methods that I don't know in the help?
In the shell I can type i.e. help(toolutils.sceneViewer) which works fine, but typing help(selectObjects) returns an error.

thanks for helping me out

regards,

Manuel
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
The means to get the last element in a list/tuple. Negative index numbers allow you to index the list from the end instead of the beginning.

selectObjects() is a method of the hou.SceneViewer class that allows you to select objects in the viewer and returns a list of hou.Node objects for the objects you selected.

help(hou.SceneViewer.selectObjects) will give you the help for the function.

dir(hou.SceneViewer) will give you a list of all methods associated with the SceneViewer class.

toolutils.sceneViewer() returns an instance of hou.SceneViewer which is displayed on the desktop.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
512 posts
Joined: July 2009
Offline
thank you Graham!
appreciated!

all the best,

Manuel
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
512 posts
Joined: July 2009
Offline
I'm still trying to cope with all the new functions, objects and methods in Python and I must admit that I still have questions about the help(),
sorry about that !
I followed the HOM introduction and wrote this in the python shell:

>>> hou.hipFile.clear()
>>> geo = hou.node('/obj').createNode('geo')
>>> box = geo.createNode('box')
>>> subd = geo.createNode('subdivide')
>>> subd.parm('iterations').set(3)
>>> subd.setFirstInput(box)
>>> subd.moveToGoodPosition() # Move the node tiles to avoid overlaps.
>>> subd.setDisplayFlag(True)
>>> subd.setRenderFlag(True)
>>> subd.setCurrent(True, clear_all_selected=True)

How can I find the all the possible commands that exist for a certain node which is not a method? In this case I created a subdivide node in the geometry level. The usage of subd.moveToGoodPosition and subd.setCurrent are clear to me, but how do I query them in the help() ??

thanks!
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
You can call help() on any object/function. Calling help on a function object gives you the usage/help for that one function. Calling it on an object will give you the help for all the methods of the object.

help(subd.moveToGoodPosition) and help(hou.Node.moveToGoodPosition) will both give you help for the moveToGoodPosition() function.

Calling help on hou.SopNode will give you the help for all the methods of a hou.SopNode object.

Also, a lot of the time I just use the online help.
http://www.sidefx.com/docs/houdini10.0/hom/hou/ [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
512 posts
Joined: July 2009
Offline
and thanks again, very helpful
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
  • Quick Links