David Derwin


About Me

United States of America


Recent Forum Posts

python bounding box display May 12, 2017, 2:29 p.m.

I've found two ways you can call your geo into the hou.BoundingBox() class. If you plug your geo node into a python sop, you can call the BoundingBox class like this:

node = hou.pwd()
geo = node.geometry()

bbox = geo.boundingBox()
print bbox 

#print information about bounding box:
print "bbox minimum and maximum bounds: " + str(bbox) 
print "bbox minvec: " + str(bbox.minvec())
print "bbox maxvec: " + str(bbox.minvec())
print "bbox size in each x,y,z axes: " + str(bbox.sizevec())
print "bbox center: " + str(bbox.center())

Or specify a sop directly, which wouldn't require having it plugged into the python sop.

bboxnode = hou.node('../OUT') 
bboxgeo = bboxnode.geometry()

bbox = bboxgeo.boundingBox()

I don't see a way for the class to automatically create a bounding box for you in the viewport, but it gives you the information required to do so.

geo.boundingBox() returns a type class ‘hou.BoundingBox’ so you cannot iterate the array directly to create points but you can get that information from minvec() and maxvec(), both of which return vectors. By combing the x, y and z values from min and max vec, you can construct the bounding box corners with points:

# create points at bounding box corners:
a = bbox.minvec()
b = (bbox.minvec()[0], bbox.maxvec()[1], bbox.minvec()[2])
c = (bbox.maxvec()[0], bbox.maxvec()[1], bbox.minvec()[2])
d = (bbox.maxvec()[0], bbox.minvec()[1], bbox.minvec()[2])
e = bbox.maxvec()
f = (bbox.maxvec()[0], bbox.minvec()[1], bbox.maxvec()[2])
g = (bbox.minvec()[0], bbox.minvec()[1], bbox.maxvec()[2])
h = (bbox.minvec()[0], bbox.maxvec()[1], bbox.maxvec()[2])

corners = [a,b,c,d,e,f,g,h]

for position in corners:
    point = geo.createPoint()

If you wanted to, you could then draw quads from the points as well, or create points the same way but from the other BoundingBox() methods, like center().

If your goal is to just create a bounding box for visualization in the viewport, you can plug your geometry into a box sop and it will create the box with the size of the bounding box of the input geometry.

I've attached a hip file which shows these different methods. I threw a transform below the test geo so you can see the bounding box react to changes in translation and rotation. Looks like both methods (python and box sop) don't create bounding boxes oriented to the geometry, which would have to be a different approach if that is your goal.

UVLayout without rotating UVs July 25, 2016, 5:11 p.m.

UVLayout is doing an excellent job laying out the UVs according to island area proportions, I'm looking for a way to restrict the UVs from being rotated when being packed, however. Maya has an option under UV Layout -> rotation -> none, which does what I'm after. Is there way to achieve this in Houdini 15.5? I see the Axis-Align Islands option but can't figure out what it does and it is not mentioned in the help document - is there a way to establish an axis direction through an attribute create perhaps? Any thoughts would be much appreciated Thanks!

OSX System Requirements update Oct. 15, 2015, 8:43 p.m.

That's great news, and thanks for the swift reply!