Jump to content
CinnamonMetal

Parent as Selected

Recommended Posts

paren = thisNode.parent()
if paren == 0:
   print(paren)
else:
    paren.setSelected(on,clear_all_selected=True)

If the current node has a parent, set the parent as the current selected node; it's unfortunately not working ? 

Share this post


Link to post
Share on other sites
parent = thisNode.parent()
if parent:
   parent.setSelected(True)

Checking if parent exists in your code makes me suspicious about your goal though. Are you actually interested in hierarchy selection or network selection? Above code returns a network which contains a node: so for /obj/geo1 it will return /obj. For the ancestors nodes you have to use parents = thisNode.inputs()

Share this post


Link to post
Share on other sites

I wanted the hierarchy selection.  ^_^

inputs() retrieves the the parent node, which I thought was the node above, the PythonSOP.  The parent node is the first node in the hierarchy. 

How do I get the node which in this case is the node one up before the PythonSOP ? As well setInput() doesn't accept index number ?

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×