Jump to content

HOM: Removing spare parameters?


pbowmar

Recommended Posts

Hi,

So I'm trying to remove spare parameters via HOM. They always are in a known folder name so I do:

# clear out the spare folder called "Output Controls"
try:
	oldParmsToClear = mantra_node.parmsInFolder(["Output Controls"])
	for curParm in oldParmsToClear:
		mantra_node.removeSpareParmTuple((curParm.name(),))
except:
	pass
	# no parms to clear

In the above, the oldParmsToClear is almost successfully filled with the list of parms. I saw almost because all the Separator parms do not show up :( Bug?

However, iterating over them and trying to remove them does nothing.

The error is:

 TypeError:  in method 'Node_removeSpareParmTuple', argument 2 of type 'HOM_ParmTuple &'

So, I need to cast to HOM_ParmTuple?? Or what exactly?

Cheers,

Peter B

Link to comment
Share on other sites

You do have to get the hou.ParmTuple for the parm:

mantra_node.removeSpareParmTuple(curParm.tuple())

This prevents you trying to do weird things with parms that have a size > 1.

It wouldn't make sense for you to be able to do something like

geo = hou.node('/obj/geo1')

geo.removeSpareParmTuple(geo.parm('tx'))

You would be changing how the 't' parameter exists so you have to get the whole parm.

Though an even better thing to do would be to do

oldParmsToClear = mantra_node.parmsTuplesInFolder(["Output Controls"])

This means you don't have to get the tuple, as well as you won't get all sorts of exceptions because it has 3 parms in a vector for example, but

calling .tuple() on it then removes the, thus causing problems with trying to delete parms already deleted now.

Also, what some people don't know is that you can do a for loop on a hou.ParmTuple object you get all the parms in the tuple.

for parm in geo.parmTuple('t'):

print parm.name()

tx

ty

tz

Edited by graham
Link to comment
Share on other sites

Hey Graham,

Cool, thanks! I was trying to do:

oldParmsToClear = mantra_node.parmsTuplesInFolder(["Output Controls"])

but the Separator parms don't show up in the list returned by parmsTuplesInFolder :(

I'm using opspare and it's working OK but I'd prefer the Folder way once it's working.

Cheers,

Peter B

  • Like 1
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...