Example #1
0
    def execute(self, context):
        keywords = self.as_keywords(ignore=("axis_forward",
                                            "axis_up",
                                            "use_selection",
                                            "global_scale",
                                            "check_existing",
                                            "filter_glob",
                                            "use_scene_unit",
                                            "use_mesh_modifiers",
                                            "batch_mode"
                                            ))

        scene = context.scene
        
        Shell = bpy.data.objects.get('Final Splint')  #Check for CORK created Shell
        if not Shell:
            Shell = bpy.data.objects.get('Splint Shell')
        
        if not Shell:
            self.report({'ERROR'}, 'You have not created your splint yet')
            return {'CANCEL'}
        
        
        #TODO, maybe give option to export the sweep surface or convex surface
        data_seq = [Shell]

        # Take into account scene's unit scale, so that 1 inch in Blender gives 1 inch elsewhere! See T42000.
        global_scale = self.global_scale
        if scene.unit_settings.system != 'NONE' and self.use_scene_unit:
            global_scale *= scene.unit_settings.scale_length

        global_matrix = axis_conversion(from_forward=self.axis_forward,
                                        from_up=self.axis_up,
                                        ).to_4x4() * Matrix.Scale(global_scale, 4)

        if self.batch_mode == 'OFF':
            faces = itertools.chain.from_iterable(
                    blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers)
                    for ob in data_seq)

            stl_utils.write_stl(faces=faces, **keywords)
        elif self.batch_mode == 'OBJECT':
            prefix = os.path.splitext(self.filepath)[0]
            keywords_temp = keywords.copy()
            for ob in data_seq:
                faces = blender_utils.faces_from_mesh(ob, global_matrix, self.use_mesh_modifiers)
                keywords_temp["filepath"] = prefix + bpy.path.clean_name(ob.name) + ".stl"
                stl_utils.write_stl(faces=faces, **keywords_temp)

        return {'FINISHED'}
Example #2
0
def export(filepath, use_mesh_modifiers=True, batch_mode='OFF'):
    global_matrix = axis_conversion(
        to_forward='Y',
        to_up='Z',
    ).to_4x4() * Matrix.Scale(1.0, 4)

    if batch_mode == 'OFF':
        faces = itertools.chain.from_iterable(
            blender_utils.faces_from_mesh(ob, global_matrix,
                                          use_mesh_modifiers)
            for ob in context.scene.objects)

        stl_utils.write_stl(faces=faces, filepath=filepath)
    elif batch_mode == 'OBJECT':
        prefix = os.path.splitext(filepath)[0]
        for ob in context.scene.objects:
            faces = blender_utils.faces_from_mesh(ob, global_matrix,
                                                  use_mesh_modifiers)
            stl_utils.write_stl(faces=faces, filepath=filepath)
    def execute(self, context):
        keywords = self.as_keywords(ignore=(
            "axis_forward",
            "axis_up",
            "global_scale",
            "check_existing",
            "filter_glob",
            "use_mesh_modifiers",
        ))

        global_matrix = axis_conversion(
            to_forward=self.axis_forward,
            to_up=self.axis_up,
        ).to_4x4() * Matrix.Scale(self.global_scale, 4)

        if self.one_file_per_object:
            basepath = os.path.splitext(self.filepath)[0]
            os.mkdir(basepath)
            print('Exporting multiple .stl files into {}'.format(basepath))
            for ob in context.selected_objects:
                stlfile = basepath + os.sep + ob.name + '.stl'
                print(stlfile)
                keywords = {'filepath': stlfile, 'ascii': self.ascii}
                faces = itertools.chain.from_iterable(
                    blender_utils.faces_from_mesh(ob, global_matrix,
                                                  self.use_mesh_modifiers)
                    for ob in [ob])
                stl_utils.write_stl(faces=faces, **keywords)
        else:
            faces = itertools.chain.from_iterable(
                blender_utils.faces_from_mesh(ob, global_matrix,
                                              self.use_mesh_modifiers)
                for ob in context.selected_objects)
            stl_utils.write_stl(faces=faces, **keywords)

        return {'FINISHED'}
Example #4
0
def get_oclSTL(operation):
    me = None
    oclSTL = ocl.STLSurf()

    for collision_object in operation.objects:
        activate(collision_object)
        if collision_object.type == "MESH":
            global_matrix = mathutils.Matrix.Identity(4)
            faces = blender_utils.faces_from_mesh(collision_object, global_matrix, operation.use_modifiers)
            for face in faces:
                t = ocl.Triangle(ocl.Point(face[0][0]*OCL_SCALE, face[0][1]*OCL_SCALE, (face[0][2]+operation.skin)*OCL_SCALE),
                        ocl.Point(face[1][0]*OCL_SCALE, face[1][1]*OCL_SCALE, (face[1][2]+operation.skin)*OCL_SCALE),
                        ocl.Point(face[2][0]*OCL_SCALE, face[2][1]*OCL_SCALE, (face[2][2]+operation.skin)*OCL_SCALE))
                oclSTL.addTriangle(t)

        # FIXME needs to work with collections
    return oclSTL
Example #5
0
            vectmod = vect
            
        radvector_mod(vectmo)        #for and proccess the object
        math_lev_mod("3*x-10")
        
        nholes = 0.003 * int(frec)
        nholes = int(nholes)

        randomize_holes(nholes,meshmap,8,4)
        bpy.ops.object.modifier_add(type='SUBSURF')
        bpy.ops.object.modifier_add(type='SUBSURF')


        facesgen=[]
        obj = bpy.context.selected_objects[0]
        facestosave = blender_utils.faces_from_mesh(obj,True,True)         #save object 
        save_object(objectpath+timedate+".stl",facestosave)
        
        print("------------ Object data ------------------")
        print("- Frquency data:" +str(frec)+" - N holes: "+str(nholes))
        print("- Legnth scream:" + str(screamlength))
        print("- Average loudness:"+ str(average))
        print("- Max loudness:" + str(maxvect))
        print("- Min loudness:" + str(minvect))
        print("- Scaling XY value: " + str(scalefactor))
        print("- Scaling Z value: " + str(zscale))

        if(debugplot == True):
            csocket.send (bytes("showplots", 'UTF-8'))
            
        # Convert and print the object. Pronsole & skeinforge #