def export2(): for (neuronName, v) in neuron_dict.items(): print('start %s' % neuronName) if neuronName[:7] == 'mu_bod_' or neuronName != 'VA10': # or neuronName in ('M1', 'RMED', 'PVDR', 'PVDL', 'IL1DL', 'IL1DR', 'I5', ): continue (v_list, f_list) = v entity = Entity() for vertex in v_list: v = vertex entity.add_vertex([round(v[0], 3), round(v[1], 3), round(v[2], 3)]) for face in f_list: entity.add_face(face) entity.neuronInfo = neuronName entity_to_cell(entity, neuronName)
def export2(): for (neuronName, v) in neuron_dict.items(): print('start %s' % neuronName) if neuronName[:7] == 'mu_bod_' or neuronName != 'VA10': # or neuronName in ('M1', 'RMED', 'PVDR', 'PVDL', 'IL1DL', 'IL1DR', 'I5', ): continue (v_list, f_list) = v entity = Entity() for vertex in v_list: v = vertex entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in f_list: entity.add_face(face) entity.neuronInfo = neuronName entity_to_cell(entity, neuronName)
def mesh_to_entity(mesh): entity = Entity() for vertex in mesh.vertices: v = vertex.co entity.add_vertex([round(v[0], 3), round(v[1], 3), round(v[2], 3)]) for face in mesh.tessfaces: cordArr = [] for v in face.vertices: write_log('+', v) cordArr.append(v) if len(cordArr) == 3: cordArr.append(cordArr[0]) write_log('=', cordArr) entity.add_face(cordArr) entity.neuronInfo = mesh.materials[0].name return entity
def mesh_to_entity(mesh): entity = Entity() for vertex in mesh.vertices: v = vertex.co entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in mesh.tessfaces: cordArr = [] for v in face.vertices: write_log('+', v) cordArr.append(v) if len(cordArr) == 3: cordArr.append(cordArr[0]) write_log('=', cordArr) entity.add_face(cordArr) entity.neuronInfo = mesh.materials[0].name return entity
def export(scene, neuronName): ''' Run export motto neurons from blender file ''' theObjects = scene.objects i = 0 for object in theObjects: try: objType=object.getType() if objType == "Mesh": if len(object.getData().materials) > 1: if( neuroNameFromOds.__contains__(object.name) and object.name == "PVDR"):# or object.name == "URBL"):#object.getData().materials[0].name != "Motor Neuron" mm=object.getMatrix() #pydevd.settrace() print object.name entity = Entity() neuronName = object.name mesh = object.getData() for vertex in mesh.verts: ob_matrix = Mathutils.Matrix(object.getMatrix('worldspace')) mm = ob_matrix blenvert = Mathutils.Vector(vertex.co) v = blenvert * mm entity.add_vertex([round(v[0],3),round(v[1],3),round(v[2],3)]) for face in mesh.faces: cordArr = [] for i in range(len(face)): indx = mesh.verts.index(face[i]) cordArr.append(indx) entity.add_face(cordArr) entity.neuronInfo = object.getData().materials[0].name entity.findCenterOfSoma() entity.find_point() create_cell(neuronName,entity) except Exception: print "Error: object named %s has problem with accessing an attribute" % object.name badNeurons.append(object.name) continue print list(badNeurons)