Diamond structure mesh generation

An open space where people who use Blender in an academic environment can share progress and the typical problems and needs of academic environments.

Moderators: jesterKing, stiv

sladak
Posts: 2
Joined: Wed Jun 27, 2012 6:17 pm

Diamond structure mesh generation

Postby sladak » Wed Jun 27, 2012 6:41 pm

Hi

I have written a script to generate a diamond structure (below). I have used cylinders to create the individual bonds. The problem is I need to mesh it such that there is no internal structure, and this is not the case where the cylinders intersect. Any ideas on how i can delete the internal structure of the bonds where the cylinders cross over, and then export it as a single object?

import bpy
#SPH V0.1
#Define cylinder width
cw=0.1 #minimum 0.1

#Define unit cell size (for one micron cylinders, take a=>2.2727273)
a=10.0

# DEFINE NUMBER OF CELLS
cellx=1
celly=1
cellz=1


#DEFINITION BLOCK - LEAVE ALONE FOR NOW

#Cylinder length
cl=0.43301*a
#Cylinder co-ord
cc=0.125*a

def makeMeshC1(x,y,z):
bpy.ops.mesh.primitive_cylinder_add(vertices=320,radius=cw,depth=cl,location=(x,y,z),rotation=(0.0,0.95531661812,0.785398))
return bpy.context.object
def makeMeshC2(x,y,z):
bpy.ops.mesh.primitive_cylinder_add(vertices=320,radius=cw,depth=cl,location=(x,y,z),rotation=(0.0,-0.95531661812,0.785398))
return bpy.context.object
def makeMeshC3(x,y,z):
bpy.ops.mesh.primitive_cylinder_add(vertices=320,radius=cw,depth=cl,location=(x,y,z),rotation=(3.14159,-0.942478,-0.785398))
return bpy.context.object
def makeMeshC4(x,y,z):
bpy.ops.mesh.primitive_cylinder_add(vertices=320,radius=cw,depth=cl,location=(x,y,z),rotation=(-3.14159,0.942478,-0.785398))
return bpy.context.object
def MakeSite(x,y,z):
makeMeshC1(x+cc,y+cc,z+cc)
makeMeshC2(x-cc,y-cc,z+cc)
makeMeshC3(x+cc,y-cc,z-cc)
makeMeshC4(x-cc,y+cc,z-cc)
bpy.ops.mesh.primitive_uv_sphere_add(size=cw,location=(x,y,z))
bpy.ops.mesh.primitive_uv_sphere_add(size=cw,location=(x+2.0*cc,y+2.0*cc,z+2.0*cc))
return bpy.context.object
def makeCell(x,y,z):
MakeSite(x,y,z)
MakeSite(x+0.5*a,y+0.5*a,z)
MakeSite(x+0.5*a,y,z+0.5*a)
MakeSite(x,y+0.5*a,z+0.5*a)
return bpy.context.object


# Structure generation run
for i in range(0,(cellx)):
for j in range(0,(celly)):
for k in range(0,(cellz)):
makeCell(i*a,j*a,k*a)

Return to “Academic & Research”

Who is online

Users browsing this forum: No registered users and 0 guests