Elyg
11/3/2017 - 4:56 PM

Create bounds box

Creates a bounding box out of selection

node = hou.selectedNodes()[0]
geo = node.geometry()


offset = hou.Vector2(0, 1.5)
pos = node.position()

bounds = geo.boundingBox()
center = bounds.center()
size = bounds.sizevec()
boxNode = node.parent().createNode("box")
transformNode = boxNode.createOutputNode("xform")

transformNode.parm("tx").set(center[0])
transformNode.parm("ty").set(center[1])
transformNode.parm("tz").set(center[2])
transformNode.parm("sx").set(size[0])
transformNode.parm("sy").set(size[1])
transformNode.parm("sz").set(size[2])
transformNode.parm("scale").set(1.1)

boxNode.setPosition(pos - offset)
transformNode.setPosition(pos - offset*2)