Houdini Python : Geometry Attribute

    There are some situations where we need to use Python SOP to manipulate the geometry,  not for replcacement of  VEX, depends on the usage.

When attribute becomes variable you can now start manipulating it.

A. Read per-elements attributes

you can acces each points dependes on the classs by using geometry class

let's say you wanna acces all of the element hat would be

node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. for prim in geo.prims(): color = prim.attribValue("Cd") print(color)






and if you wanna write 

node = hou.pwd() geo = node.geometry() #declare attribute first geo.addAttrib(hou.attribType.Prim,"name","") for prim in geo.prims(): prim.setAttribValue("name","iceX")






B. Detail a.k.a Global Attributes is a bit different since you read this at once.

Decalare attributes

node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. test = "hello!" geo.addAttrib(hou.attribType.Global, "test", "") geo.setGlobalAttribValue("test", test)





Read Attributes

node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. attrib = geo.attribValue("test") print(attrib)