Jump to content
newPeak

How to create black box asset use python ?

Recommended Posts

If you put this in a python sop it will give you a black box.

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

points = []

geo.addAttrib(hou.attribType.Point, "Cd",(0.02,0.02,0.02))
geo.addAttrib(hou.attribType.Vertex, "N",(-1.0,0.0,0.0),True) 

#create points
for x in (-1,1):
    for y in (-1,1):
        for z in (-1,1):
            new_point = geo.createPoint()
            new_point.setPosition((x,y,z)) 
            points.append(new_point)

#create faces
polygons = [
    (2,3,1,0),
    (1,3,7,5),
    (5,7,6,4),
    (4,6,2,0),
    (7,3,2,6),
    (1,5,4,0),
]

for point_numbers in polygons:
    poly_points = [points[x] for x in point_numbers]
    v1 = poly_points[0].position() - poly_points[1].position()
    v2 = poly_points[1].position() - poly_points[2].position()
    normal = (v2.cross(v1)).normalized()
    new_poly = geo.createPolygon()
    for point in poly_points:
        new_vertex = new_poly.addVertex(point)
        new_vertex.setAttribValue("N",normal)
        
        

 

  • Like 1

Share this post


Link to post
Share on other sites

Funny :lol: but he's asking how to create a Black Boxed Asset (what you make by using the "Assets > Create Black Boxed Asset from Section" menu)

I have the same question - is there any way to trigger this "Create Black Boxed Asset" from code, either python or vex? I don't see anything under hou.hda

 

EDIT: Found the answer here: 

 

 

Edited by kgmcnamara

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

×