Jump to content

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
Link to comment
Share on other sites

  • 1 year later...

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...