Jump to content

how to set the scope of a shelf script.


Symbolic

Recommended Posts

Hi,

I have a script that is doing some simple automation. But I would like this script to be able to work only when I am inside a certain geometry node.

right now I use:

focus="/obj/geo1/"

so I can tell the script where to operate. Is there a way of doing this automaticly. Like If I am in the network... any geometry network... and I hit the button on shelf... it works.

Right now, if I do not hardcode the scope path... when I execute the script... it thinks that it is at the top level of Houdini. When I list nodes, it lists only OBJ, VEX etc.... nothing related to the actual scope that I am working in.

Thanks.

Link to comment
Share on other sites

You can get the current path from the viewport using the toolutils module:

import toolutils
view = toolutils.sceneViewer()
curpath = view.pwd()

curpath is now a node object for whatever's displaying in the viewport.

You can then check to see if it's a geometry node:

if curpath.childTypeCategory() == hou.sopNodeTypeCategory():
	 print 'yay'

At least I'm pretty sure that'll work.

-z

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...