Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created May 13, 2014 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/3e30ff70bb6a4466b05e to your computer and use it in GitHub Desktop.
Save zeffii/3e30ff70bb6a4466b05e to your computer and use it in GitHub Desktop.
import numpy as np
def sv_main(verts=[]):
in_sockets = [['v', 'Verts', verts]]
out_sockets = [['v', 'Verts', []], ['s', 'Edges', []]]
if not verts:
return in_sockets, out_sockets
# get numpy array for fastness
nv = np.array(verts)
bbox = []
for dim in range(3):
bbox.extend([nv[:,dim].min(), nv[:,dim].max()])
minx, maxx, miny, maxy, minz, maxz = bbox
# order is important
a = (maxx, maxy, minz)
b = (maxx, miny, minz)
c = (minx, miny, minz)
d = (minx, maxy, minz)
e = (maxx, maxy, maxz)
f = (maxx, miny, maxz)
g = (minx, miny, maxz)
h = (minx, maxy, maxz)
verts_out = [a,b,c,d,e,f,g,h]
edges_out = [
(0,1),(1,2),(2,3),(3,0), # bottom edges
(4,5),(5,6),(6,7),(7,4), # top edges
(0,4),(1,5),(2,6),(3,7) # sides
]
out_sockets[0][2] = [verts_out]
out_sockets[1][2] = [edges_out]
return in_sockets, out_sockets
@ly29
Copy link

ly29 commented May 13, 2014

Try something like this, might have to adjust for order desired order, like bottom first then top

>>> list(itertools.product(('-x','x'),('-y','y'),('-z','z')))
[('-x', '-y', '-z'), ('-x', '-y', 'z'), ('-x', 'y', '-z'), ('-x', 'y', 'z'), ('x', '-y', '-z'), ('x', '-y', 'z'), ('x', 'y', '-z'), ('x', 'y', 'z')]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment