Référencer le node courant#
node = hou.pwd()
node_name = node.name() # Get the name of the current node
parent = node.parent() # Get the parent node
path = node.path() # Get the full path of the node
geo = node.geometry()
prims = geo.globPrims("0")
print(prims)
name = prims[0].attribValue("name")
node.setName("koko")
Définir la valeur d’un attribut#
node = hou.pwd()
geo = node.geometry()
for prim in geo.prims():
number = prim.number()
prim.setAttribValue("name", "fragment_" + str(number))
Ajouter des attributs#
node = hou.pwd()
geo = node.geometry()
geo.addAttrib(hou.attribType.Prim, "newAttrib", "neAttrib")
for prim in geo.prims():
number = prim.number()
prim.setAttribValue("ef", "fragment_" + str(number))
Manipulation des groupes#
node = hou.pwd()
geo = node.geometry()
cd = (0,1,0)
geo.addAttrib(hou.attribType.Point, "Cd", cd)
grp = geo.createPointGroup("myptgroup")
mypts = geo.globPoints("0-50")
for pt in mypts:
grp.add(pt)
pt.setAttribValue("Cd", (1,0,0))
Créer un groupe avec une bounding box#
node = hou.pwd()
geo = node.geometry()
box = node.inputs()[1].geometry().boundingBox()
cd = (0,1,0)
geo.addAttrib(hou.attribType.Point, "Cd", cd)
grp = geo.createPointGroup("myptgroup")
for pt in geo.points():
pos = pt.position()
included = box.contains(pos)
if included == 1:
grp.add(pt)
pt.setAttribValue("Cd", (1,0,0))
geo.deletePoints(grp.points())
Points les plus proches : voisins de points#
import hou
node = hou.pwd()
geo = node.inputs()[1].geometry()
cd = (0,1,0)
geo.addAttrib(hou.attribType.Point, "Cd", cd)
grp = geo.createPointGroup("myptgroup")
for pt in box.points():
pos = pt.position()
nearpts = geo.nearestPoints(pos, 100, None, 1)
for nearpt in nearpts:
nearpt.setAttribValue("Cd", (1,0,0))