Jump to content
Sari_Y

Get prim attribute value via python

Recommended Posts

Hi. Guys. 

I'm stuck python scripts. How to get "name" attribute value at prim via python? I would replace the Null name with it.
Python scripts is new to me. I'm not sure error meaning.

Please give me some advice. Thanks!

Saori

 

Q_py_getattribval.jpg

Share this post


Link to post
Share on other sites

Hi Saori, we have to reference the node`s Geometry, not the node itself. Try this:

geo = hou.node("/obj/GEO_model/null1").geometry()
geo.attribValue("name")

Or, this is the same:

node = hou.node("/obj/GEO_model/null1")
geo = node.geometry()
geo.attribValue("name")

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi Saori-san, :)

You need to access the geometry on your hou.Node instance. For example:

hou.node("/obj/GEO_model/null1").geometry().attribValue("name")

 

  • Like 2

Share this post


Link to post
Share on other sites

also since you are trying to access prim attribute value you need to get a single prim first

hou.node("/obj/GEO_model/null1").geometry().iterPrims()[0].attribValue("name")

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

cool! I got it. Thanks for your time guys!

null         = hou.node("/obj/GEO_model/null1")
nullname = null.geometry().iterPrims()[0].attribValue('name')
null.setName(nullname)

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

×