Python Parameters function?

   4632   12   0
User Avatar
Member
97 posts
Joined: May 2015
Offline
Is there a python function to get all the parameter within a folder but the folder is a multiparm block?

Attachments:
Screenshot (768).png (216.3 KB)

User Avatar
Member
8 posts
Joined: April 2020
Offline
Are you asking how to get the nested folder params?

If so, say you wanted ‘Rings’ is would be:

For flat parms:
node.parmsInFolder(('Poles', 'Rings'))
For tuple params:
node.parmTuplesInFolder(('Poles', 'Rings'))
Edited by dom_campbell - July 11, 2020 09:08:34
User Avatar
Member
97 posts
Joined: May 2015
Offline
dom_campbell
Are you asking how to get the nested folder params?

If so, say you wanted ‘Rings’ is would be:

For flat parms:
node.parmsInFolder(('Poles', 'Rings'))
For tuple params:
node.parmTuplesInFolder(('Poles', 'Rings'))

I get an error saying “OperationFailed: The attempted operation failed.
Invalid containing folder name(s)” the parameters are on a Digital Asset.
Edited by Shadowjonny - July 11, 2020 21:17:47
User Avatar
Member
7741 posts
Joined: Sept. 2011
Offline
if its a multiparm, use multiParmInstances() on the parm.
User Avatar
Member
97 posts
Joined: May 2015
Offline
jsmack
if its a multiparm, use multiParmInstances() on the parm.

i did but i get all the instances. I just want to get the names of the parameters that are in the multiparm block
Edited by Shadowjonny - July 12, 2020 03:52:49
User Avatar
Member
8 posts
Joined: April 2020
Offline
Calling from/on a hda is not going to make a difference as long as you are calling on the correct `Node`.

A couple of things to check if you are calling it on a non-nested folder you need to make it clear it is a tuple with a trailing `,`; use node.parmTuplesInFolder(('Poles', ))not node.parmTuplesInFolder(('Poles')).

Second thing to check is that you are using the folder's ‘label’ and not it's ‘name’; I know the error says name but for me it sees to require the ‘label’.

In the below you would use ‘First’ not ‘folder0’.
Edited by dom_campbell - July 12, 2020 05:42:59

Attachments:
Screenshot 2020-07-12 at 10.33.12.png (107.0 KB)

User Avatar
Member
97 posts
Joined: May 2015
Offline
dom_campbell
Calling from/on a hda is not going to make a difference as long as you are calling on the correct `Node`.

A couple of things to check if you are calling it on a non-nested folder you need to make it clear it is a tuple with a trailing `,`; use node.parmTuplesInFolder(('Poles', ))not node.parmTuplesInFolder(('Poles')).

Second thing to check is that you are using the folder's ‘label’ and not it's ‘name’; I know the error says name but for me it sees to require the ‘label’.

In the below you would use ‘First’ not ‘folder0’.

HDAnode = hou.node("/obj/UtilityPole")  
list = HDAnode.parmTuplesInFolder(("Poles", "Rings"))

I get the Operation failed. That is there name, what do you mean by trailing?
User Avatar
Member
8 posts
Joined: April 2020
Offline
Shadowjonny
what do you mean by trailing?

For the trailing ‘,’. I just mean that if you had one item in the tuple you needed a `,` at the end (trailing) to make it a tuple containing one string, leaving it out would make it just a string with bracket around it; `(“Poles”) == “Poles”` not `(“Poles”, )`. You have to values in the tuple so it will be fine.

Shadowjonny
That is there name

No “Poles” and “Rings” look like the labels to me which is what you should be using in `parmTuplesInFolder`. Most on the when accessing things you should be using the names, but not in this case; I dont know why but I am a n00b so maybe the reason is obvious to others.

No sure what will is up with your setup `parmTuplesInFolder()` works as fine for me.

Ask which version you are on? (I am new to Houdini so have only used version 18 and maybe there is a difference)
The version changes '#' characters to '_' when I apply so the screen shot you have could not be applied changes; and obviously you would need to apply the changes before anything would work. Maybe there is some issue with using `#` in the names.

Can you confirm
HDAnode
is differently the correct node?

Can you confirm it's type
HDAnode.type()
?

Where is this python code running from?
I would expect
hou.pwd()
to have been used if it was inside the hda;
hou.node("/obj/UtilityPole")
would only be the right thing to do in session code since it is a scene content path.

Can you access the parms okay? Does
HDAnode.parm('RingPosition#_#x')
return a value okay? or
HDAnode.parm('RingPosition___x')
if it was renamed on apply?

If the parm is returned are does it say the containing folders are?
HDAnode.parm('RingPosition#_#x').containingFolders()
or it the parm was renamed on apply
HDAnode.parm('RingPosition___x').containingFolders()

Is `parmTuplesInFolder` working in general for you?
Does
HDAnode.parmTuplesInFolder(())
return all the parms? (yes, when there is no values in the tuple it knows it is a tuple, one value is just the odd case)

Does
HDAnode.parmTuplesInFolder(('Poles', ))
return all everything in the poles folder?

Sorry, if some of those are a bit obvious and they are a bit confusing. With Houdini a user could some could be an experienced artist but inexperienced programmer, or an experienced programmer but inexperienced artist; those groups don't speak the same language or make the same sort of mistakes.
Edited by dom_campbell - July 12, 2020 14:52:08
User Avatar
Member
97 posts
Joined: May 2015
Offline
dom_campbell
Shadowjonny
what do you mean by trailing?

For the trailing ‘,’. I just mean that if you had one item in the tuple you needed a `,` at the end (trailing) to make it a tuple containing one string, leaving it out would make it just a string with bracket around it; `(“Poles”) == “Poles”` not `(“Poles”, )`. You have to values in the tuple so it will be fine.

Shadowjonny
That is there name

No “Poles” and “Rings” look like the labels to me which is what you should be using in `parmTuplesInFolder`. Most on the when accessing things you should be using the names, but not in this case; I dont know why but I am a n00b so maybe the reason is obvious to others.

No sure what will is up with your setup `parmTuplesInFolder()` works as fine for me.

Ask which version you are on? (I am new to Houdini so have only used version 18 and maybe there is a difference)
The version changes '#' characters to '_' when I apply so the screen shot you have could not be applied changes; and obviously you would need to apply the changes before anything would work. Maybe there is some issue with using `#` in the names.

Can you confirm
HDAnode
is differently the correct node?

Can you confirm it's type
HDAnode.type()
?

Where is this python code running from?
I would expect
hou.pwd()
to have been used if it was inside the hda;
hou.node("/obj/UtilityPole")
would only be the right thing to do in session code since it is a scene content path.

Can you access the parms okay? Does
HDAnode.parm('RingPosition#_#x')
return a value okay? or
HDAnode.parm('RingPosition___x')
if it was renamed on apply?

If the parm is returned are does it say the containing folders are?
HDAnode.parm('RingPosition#_#x').containingFolders()
or it the parm was renamed on apply
HDAnode.parm('RingPosition___x').containingFolders()

Is `parmTuplesInFolder` working in general for you?
Does
HDAnode.parmTuplesInFolder(())
return all the parms? (yes, when there is no values in the tuple it knows it is a tuple, one value is just the odd case)

Does
HDAnode.parmTuplesInFolder(('Poles', ))
return all everything in the poles folder?

Sorry, if some of those are a bit obvious and they are a bit confusing. With Houdini a user could some could be an experienced artist but inexperienced programmer, or an experienced programmer but inexperienced artist; those groups don't speak the same language or make the same sort of mistakes.

so i tired all of those they work and they print out something only the ‘containingFolders()’ was empty. Also
 HDAnode.parmTuplesInFolder(()) 
worked but
HDAnode.parmTuplesInFolder(('Poles', ))
didnt work weird. I dont know if i forgot to say im writing this in a Python SOP. If i do
 HDAnode.parm("RingPosition_1_1").eval()
i get the eval so its reading the path right. =/
User Avatar
Member
97 posts
Joined: May 2015
Offline
Honestly i dont know why houdini python is hard for me to get. Doesnt take me long in maya to know what im looking for, and VEX is super easy to understand but idk if that cause i mainly write code in c++.
User Avatar
Member
8 posts
Joined: April 2020
Offline
containingFolders does not work on tuple parms. Try the individual parm.
HDAnode.parm("RingPosition_1_1x").containingFolders()
User Avatar
Member
97 posts
Joined: May 2015
Offline
dom_campbell
containingFolders does not work on tuple parms. Try the individual parm.
HDAnode.parm("RingPosition_1_1x").containingFolders()

The ‘RingPosition_1_1’ is a float value

Attachments:
Screenshot (770).png (781.1 KB)

User Avatar
Member
8 posts
Joined: April 2020
Offline
Shadowjonny
the folder is a multiparm block

Apologies, I completely misunderstood this and thought you meant parms that are tuples (like a vector3) in a folder. I did not realise multiparm blocks where folder types that automatically created list templates. Sorry, I am new to Houdini

Yes, I can config parmInFolder/parmTuplesInFolder do not return anything for these types (I am guessing that is a bug); so the parms are not in the folders.

The 2 options at I am aware you will have (and I am guessing you may know already) are, globParms or evaluation the folder parm to get the number of instances;
# Probably not what you want given you have a nested multiparm block folders and you will need the indices.
# Would be fine for not nested as they are in order
ringPositions = HDAnode.globParms("RingPosition*")

# This time you do need to use the folder names NOT THE LABELS
for i in range(0, HDAnode.evalParm('polesName')):
    adjustedI = i + 1
    for j in range(0, HDAnode.evalParm('ringsName{}'.format(adjustedI))):
        adjustedJ = j + 1
        ringPosition = HDAnode.evalParm("RingPosition{}_{}".format(adjustedI, adjustedJ))
        # etc
Edited by dom_campbell - July 13, 2020 12:01:44
  • Quick Links