def main():
    pipeInnerInput = Blender.Draw.Create(48)
    pipeOuterInput = Blender.Draw.Create(50)
    pipeDivInput = Blender.Draw.Create(64)
    pipeHDivInput = Blender.Draw.Create(1)
    pipeRDivInput = Blender.Draw.Create(1)
    pipeHeightInput = Blender.Draw.Create(1.0)

    block = []
    block.append(
        ("Inner radius:", pipeInnerInput, 0.01, 100, "the inner radius"))
    block.append(
        ("Outer radius:", pipeOuterInput, 0.01, 100, "the outer radius"))
    block.append(("Divisions:", pipeDivInput, 4, 100, "number of divisions"))
    block.append(
        ("Height:", pipeHeightInput, 1.00, 100, "the height of the pipe"))
    block.append(("Height divisions:", pipeHDivInput, 1, 100,
                  "number of height divisions"))
    block.append(("Radial divisions:", pipeRDivInput, 1, 100,
                  "number of radial divisions"))

    if not Blender.Draw.PupBlock("Lay pipe", block):
        return


#	Generates the mesh
    verts, faces = add_pipe(pipeDivInput.val, pipeHDivInput.val,
                            pipeRDivInput.val, pipeInnerInput.val,
                            pipeOuterInput.val, pipeHeightInput.val)

    #	Adds the mesh to the scene
    BPyAddMesh.add_mesh_simple('Pipe', verts, [], faces)
Example #2
0
def main():
	Draw = Blender.Draw
	PREF_MAJOR_RAD = Draw.Create(1.0)
	PREF_MINOR_RAD = Draw.Create(0.1)
	PREF_OFFSET = Draw.Create(0.0)
	PREF_SEG = Draw.Create(36)

	if not Draw.PupBlock('Add Cylinder Intersection', [\
	('Major Radius:', PREF_MAJOR_RAD,  0.001, 10000, 'Radius for the bigger cylinder'),\
	('Minor Radius:', PREF_MINOR_RAD,  0.001, 10000, 'Radius for the smaller cylinder'),\
	('Axis Offset:', PREF_OFFSET,  0.000, 10000, 'Axix offset between smaller and bigger cylinder'),\
	('Segments:', PREF_SEG,  3, 256, 'Number of segments for the intersection (circle)'),\
	]):
		return
	
	verts, faces = add_cylinters(PREF_MAJOR_RAD.val, PREF_MINOR_RAD.val, PREF_OFFSET.val, PREF_SEG.val)
	
	BPyAddMesh.add_mesh_simple('CylInters', verts, [], faces)
Example #3
0
def main():
	Draw = Blender.Draw
	PREF_MAJOR_RAD = Draw.Create(1.0)
	PREF_MINOR_RAD = Draw.Create(0.25)
	PREF_MAJOR_SEG = Draw.Create(48)
	PREF_MINOR_SEG = Draw.Create(16)

	if not Draw.PupBlock('Add Torus', [\
	('Major Radius:', PREF_MAJOR_RAD,  0.01, 100, 'Radius for the main ring of the torus'),\
	('Minor Radius:', PREF_MINOR_RAD,  0.01, 100, 'Radius for the minor ring of the torus setting the thickness of the ring'),\
	('Major Segments:', PREF_MAJOR_SEG,  3, 256, 'Number of segments for the main ring of the torus'),\
	('Minor Segments:', PREF_MINOR_SEG,  3, 256, 'Number of segments for the minor ring of the torus'),\
	]):
		return
	
	verts, faces = add_torus(PREF_MAJOR_RAD.val, PREF_MINOR_RAD.val, PREF_MAJOR_SEG.val, PREF_MINOR_SEG.val)
	
	BPyAddMesh.add_mesh_simple('Torus', verts, [], faces)
Example #4
0
def main():
	Draw = Blender.Draw
	PREF_MAJOR_RAD = Draw.Create(1.0)
	PREF_MINOR_RAD = Draw.Create(0.25)
	PREF_MAJOR_SEG = Draw.Create(48)
	PREF_MINOR_SEG = Draw.Create(16)

	if not Draw.PupBlock('Add Torus', [\
	('Major Radius:', PREF_MAJOR_RAD,  0.01, 100, 'Radius for the main ring of the torus'),\
	('Minor Radius:', PREF_MINOR_RAD,  0.01, 100, 'Radius for the minor ring of the torus setting the thickness of the ring'),\
	('Major Segments:', PREF_MAJOR_SEG,  3, 256, 'Number of segments for the main ring of the torus'),\
	('Minor Segments:', PREF_MINOR_SEG,  3, 256, 'Number of segments for the minor ring of the torus'),\
	]):
		return
	
	verts, faces = add_torus(PREF_MAJOR_RAD.val, PREF_MINOR_RAD.val, PREF_MAJOR_SEG.val, PREF_MINOR_SEG.val)
	
	BPyAddMesh.add_mesh_simple('Torus', verts, [], faces)
Example #5
0
def readGmsh2(filename):
    Blender.Window.WaitCursor(1)
    Vector = Blender.Mathutils.Vector

    file = open(filename, 'r')

    line = file.readline()
    line = file.readline()
    line = file.readline()
    line = file.readline()
    line = file.readline()
    words = line.split()
    if len(words) != 1:
        Blender.Draw.PupMenu('Error%t|File format error 1')
        return
    num_nodes = int(float(words[0]))
    verts = []
    for i in range(0, num_nodes):
        line = file.readline()
        words = line.split()
        if len(words) != 4:
            Blender.Draw.PupMenu('Error%t|File format error 2')
            return
        x = float(words[1])
        y = float(words[2])
        z = float(words[3])
        verts.append(Vector(x, y, z))

    line = file.readline()
    line = file.readline()
    line = file.readline()
    words = line.split()
    if len(words) != 1:
        Blender.Draw.PupMenu('Error%t|File format error 3')
        return
    num_elements = int(float(words[0]))
    faces = []
    for i in range(0, num_elements):
        line = file.readline()
        words = line.split()
        if len(words) < 3:
            Blender.Draw.PupMenu('Error%t|File format error 4')
            return
        element_type = int(float(words[1]))
        num_tags = int(float(words[2]))
        read_element = 0
        if element_type == 2:
            if len(words) != 3 + 3 + num_tags:
                Blender.Draw.PupMenu('Error%t|File format error 5')
                return
            read_element = 1
        if element_type == 3:
            if len(words) != 3 + 4 + num_tags:
                Blender.Draw.PupMenu('Error%t|File format error 6')
                return
            read_element = 1
        if read_element == 1:
            face_verts = []
            for j in range(3 + num_tags, len(words)):
                idx = int(float(words[j])) - 1
                face_verts.append(idx)
            faces.append(face_verts)

    BPyAddMesh.add_mesh_simple('gmsh_object', verts, [], faces)

    Blender.Window.WaitCursor(0)
    Blender.Window.RedrawAll()
Example #6
0
def readGmsh2(filename):
  Blender.Window.WaitCursor(1)
  #mesh = Blender.NMesh.New()
  Vector = Blender.Mathutils.Vector
  
  file = open(filename, 'r')
  
  line = file.readline()
  line = file.readline()
  line = file.readline()
  line = file.readline()
  line = file.readline()
  words = line.split()
  if len(words) != 1:
    Blender.Draw.PupMenu('Error%t|File format error 1')
    return
  num_nodes = int(float(words[0]))
  verts = []
  for i in range(0, num_nodes):
    line = file.readline()
    words = line.split()
    if len(words) != 4:
      Blender.Draw.PupMenu('Error%t|File format error 2')
      return
    x = float(words[1])
    y = float(words[2])
    z = float(words[3])
    verts.append( Vector(x,y,z) )
    
  line = file.readline()
  line = file.readline()
  line = file.readline()
  words = line.split()
  if len(words) != 1:
    Blender.Draw.PupMenu('Error%t|File format error 3')
    return
  num_elements = int(float(words[0]))
  faces = []
  for i in range(0, num_elements):
    line = file.readline()
    words = line.split()
    if len(words) < 3:
      Blender.Draw.PupMenu('Error%t|File format error 4')
      return
    element_type = int(float(words[1]))
    num_tags = int(float(words[2]))
    read_element = 0
    if element_type == 2:
      if len(words) != 3 + 3 + num_tags:
        Blender.Draw.PupMenu('Error%t|File format error 5')
        return
      read_element = 1
    if element_type == 3:
      if len(words) != 3 + 4 + num_tags:
        Blender.Draw.PupMenu('Error%t|File format error 6')
        return
      read_element = 1
    if read_element == 1:
      face_verts = []
      for j in range(3+num_tags, len(words)):
        idx = int(float(words[j])) - 1
        face_verts.append(idx)
      faces.append(face_verts)
      
  BPyAddMesh.add_mesh_simple('gmsh_object', verts, [], faces)
	        
  Blender.Window.WaitCursor(0)
  Blender.Window.RedrawAll()
Example #7
0
def main():
    BPyAddMesh.add_mesh_simple('EmptyMesh', [], [], [])
Example #8
0
sce = bpy.data.scenes.active
for k,v in d.items():
	y = 0.0 
	x = 0.0
	z = 0.0
	x2 = v.duration
	y2 = v.velocity/64;
	str = ''
	for n in v.name:
		str += n
	

	 #print(x,x2,y,y2,str,v.name)
	verts, faces = add_mymesh(x,x2,y,y2)
	BPyAddMesh.add_mesh_simple(str, verts, [], faces) 
	
	timeline = v.start
	time = v.start * 25
	duration = 	v.duration * 25
	vel = v.velocity
	pitch = 		v.pitch
	channel = v.channel

		
					
	obj = Blender.Object.Get(str)
	if obj:
		temp = obj.getLocation()
		temp = [timeline + temp[0], ((channel-1))*2.169 + temp[1], v.velocity/127]
		print temp
Example #9
0
def readEngrid(filename):
    Blender.Window.WaitCursor(1)
    Vector = Blender.Mathutils.Vector

    in_file = file(filename, "r")
    line = in_file.readline()
    Nobjects = int(line)
    #print "Nobjects=",Nobjects
    object_names = []
    for i in range(0, Nobjects):
        line = in_file.readline()
        object_names.append(line.strip())

    #print "object_names=",object_names

    global_verts = []
    offset = 0
    for i_object in range(0, Nobjects):
        line = in_file.readline()
        words = line.split()
        Nverts = int(words[0])
        Nfaces = int(words[1])
        #print "Nverts=",Nverts
        #print "Nfaces=",Nfaces

        local_verts = []
        for i_vert in range(0, Nverts):
            line = in_file.readline()
            words = line.split()
            x = float(words[0])
            y = float(words[1])
            z = float(words[2])
            #print "x,y,z=",x,y,z
            local_verts.append(Vector(x, y, z))
            global_verts.append(Vector(x, y, z))

        faces = []
        for i_face in range(0, Nfaces):
            line = in_file.readline()
            words = line.split()
            if len(words) < 3:
                Blender.Draw.PupMenu('Error%t|File format error 4')
                return
            Nverts_in_face = int(words[0])
            if len(words) != 1 + Nverts_in_face:
                Blender.Draw.PupMenu('Error%t|File format error 5')
                return
            face_verts = []
            for i_face_vert in range(0, Nverts_in_face):
                idx = int(words[i_face_vert + 1]) - offset
                face_verts.append(idx)
            #print "face_verts=",face_verts
            faces.append(face_verts)

        #print "Adding object ",object_names[i_object]
        BPyAddMesh.add_mesh_simple(object_names[i_object], local_verts, [],
                                   faces)

        offset += Nverts

    in_file.close()

    Blender.Window.WaitCursor(0)
    Blender.Window.RedrawAll()
Example #10
0
def readEngrid(filename):
  Blender.Window.WaitCursor(1)
  Vector = Blender.Mathutils.Vector
  
  in_file = file(filename, "r")
  line = in_file.readline()
  Nobjects = int(line)
  #print "Nobjects=",Nobjects
  object_names = []
  for i in range(0, Nobjects):
    line = in_file.readline()
    object_names.append(line.strip())
  
  #print "object_names=",object_names
  
  global_verts = []
  offset = 0
  for i_object in range(0, Nobjects):
    line = in_file.readline()
    words = line.split()
    Nverts = int(words[0])
    Nfaces = int(words[1])
    #print "Nverts=",Nverts
    #print "Nfaces=",Nfaces
    
    local_verts = []
    for i_vert in range(0, Nverts):
      line = in_file.readline()
      words = line.split()
      x = float(words[0])
      y = float(words[1])
      z = float(words[2])
      #print "x,y,z=",x,y,z
      local_verts.append( Vector(x,y,z) )
      global_verts.append( Vector(x,y,z) )
    
    faces = []
    for i_face in range(0, Nfaces):
          line = in_file.readline()
          words = line.split()
          if len(words) < 3:
            Blender.Draw.PupMenu('Error%t|File format error 4')
            return
          Nverts_in_face = int(words[0])
          if len(words) != 1 + Nverts_in_face:
            Blender.Draw.PupMenu('Error%t|File format error 5')
            return
          face_verts = []
          for i_face_vert in range(0, Nverts_in_face):
            idx = int(words[i_face_vert + 1]) - offset
            face_verts.append(idx)
          #print "face_verts=",face_verts
          faces.append(face_verts)
    
    #print "Adding object ",object_names[i_object]
    BPyAddMesh.add_mesh_simple(object_names[i_object], local_verts, [], faces)

    offset += Nverts

  in_file.close()

  Blender.Window.WaitCursor(0)
  Blender.Window.RedrawAll()
Example #11
0
def main():
	BPyAddMesh.add_mesh_simple('EmptyMesh', [], [], [])