__idname__ = "export.autodesk_3ds" __label__ = 'Export 3DS' # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. __props__ = [ # bpy.props.StringProperty(attr="filename", name="File Name", description="File name used for exporting the 3DS file", maxlen= 1024, default= ""), bpy.props.StringProperty(attr="path", name="File Path", description="File path used for exporting the 3DS file", maxlen= 1024, default= ""), ] def execute(self, context): save_3ds(self.path, context) return ('FINISHED',) def invoke(self, context, event): wm = context.manager wm.add_fileselect(self.__operator__) return ('RUNNING_MODAL',) def poll(self, context): # Poll isnt working yet print("Poll") return context.active_object != None bpy.ops.add(EXPORT_OT_autodesk_3ds) # Add to a menu import dynamic_menu menu_func = lambda self, context: self.layout.itemO("export.autodesk_3ds", text="Autodesk 3DS...") menu_item = dynamic_menu.add(bpy.types.INFO_MT_file_export, menu_func)
mesh = bpy.data.add_mesh( "pyramid" ) mesh.add_geometry( int(len( verts )/3), 0, int(len( faces )/4) ) mesh.verts.foreach_set( "co", verts ) mesh.faces.foreach_set( "verts_raw", faces ) scene = context.scene for ob in scene.objects: ob.selected = False mesh.update() # link the mesh data to a mesh object # then put it into the scene. ob_new = bpy.data.add_object( 'MESH', "Pyramid" ) ob_new.data = mesh scene.objects.link( ob_new ) scene.objects.active = ob_new ob_new.selected = True ob_new.location = tuple( context.scene.cursor_location ) return( 'FINISHED', ) # standard operation registration and menu setup. bpy.ops.add( OBJECT_OT_PyramidOp ) import dynamic_menu menuFunc = ( lambda self, context: self.layout.operator( OBJECT_OT_PyramidOp.bl_idname, text="Pyramid" ) ) menu_item = dynamic_menu.add( bpy.types.INFO_MT_mesh_add, menuFunc )
me.add_geometry(int(len(verts_loc)/3), 0, int(len(faces)/4)) me.verts.foreach_set("co", verts_loc) me.faces.foreach_set("verts_raw", faces) sce = context.scene # ugh for ob in sce.objects: ob.selected = False me.update() ob= bpy.data.add_object('MESH', "Torus") ob.data= me context.scene.add_object(ob) context.scene.active_object = ob ob.selected = True ob.location = tuple(context.scene.cursor_location) return ('FINISHED',) # Register the operator bpy.ops.add(MESH_OT_primitive_torus_add) # Add to a menu import dynamic_menu import space_info menu_item = dynamic_menu.add(bpy.types.INFO_MT_mesh_add, (lambda self, context: self.layout.itemO("mesh.primitive_torus_add", text="Torus", icon='ICON_MESH_DONUT')) ) if __name__ == "__main__": bpy.ops.mesh.primitive_torus_add()