Created
April 6, 2018 07:43
-
-
Save paulwinex/13e626a5f246592cf8b004b1a19272af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node = hou.pwd() | |
geo = node.geometry() | |
pos_array = [] | |
index_array = [] | |
for pt in geo.iterPoints(): | |
pos_array.append(pt.position()) | |
index_array.append(pt.number()) | |
poly_array = [] | |
type_array = [] | |
for prim in geo.iterPrims(): | |
poly_con = [] | |
for vert in prim.vertices(): | |
poly_con.append(vert.point().number()) | |
type_array.append(prim.type().name()) | |
poly_array.append(poly_con) | |
# create new prim | |
geo.clear() # clear geo | |
up = 1 # up | |
# points | |
points = [] | |
for i, pos in sorted(enumerate(pos_array), key=lambda i: index_array[i[0]]): | |
pt = geo.createPoint() | |
pt.setPosition((pos[0], pos[1]+up, pos[2]) ) | |
points.append(pt) | |
# prims | |
for pr in poly_array: | |
poly = geo.createPolygon() | |
poly.setIsClosed(False) | |
for pt in pr: | |
poly.addVertex(points[pt]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment