import Blender
from Blender import *
OB = Object.GetSelected()
BBB=[[OB[0].getBoundBox()[0][0],
OB[0].getBoundBox()[0][1],
OB[0].getBoundBox()[0][2]],
[OB[0].getBoundBox()[0][0],
OB[0].getBoundBox()[0][1],
OB[0].getBoundBox()[0][2]]
]
for ob in OB :
B=ob.getBoundBox()
for b in B:
for n in [0,1,2]:
BBB[0][n]=min(BBB[0][n],b[n])
BBB[1][n]=max(BBB[1][n],b[n])
SC=Scene.getCurrent()
min=BBB[0]
max=BBB[1]
from Blender import NMesh
vertices_list=[
[min[0],min[1],min[2]],
[min[0],max[1],min[2]],
[max[0],max[1],min[2]],
[max[0],min[1],min[2]],
[min[0],min[1],max[2]],
[min[0],max[1],max[2]],
[max[0],max[1],max[2]],
[max[0],min[1],max[2]]
]
faces_list=[[0,1,2,3],
[4,7,6,5],
[0,4,5,1],
[1,5,6,2],
[2,6,7,3],
[4,0,3,7]]
A_CUBE_MESH=NMesh.GetRaw()
for coordinate in vertices_list:
A_VERTEX=NMesh.Vert(coordinate[0], coordinate[1],
coordinate[2])
A_CUBE_MESH.verts.append(A_VERTEX)
for thisface in faces_list:
A_FACE=NMesh.Face()
for vertexpos in thisface:
A_FACE.append(A_CUBE_MESH.verts[vertexpos])
A_CUBE_MESH.faces.append(A_FACE)
NMesh.PutRaw(A_CUBE_MESH,'Cube')
Blender.Redraw() |