Guest User

3d menu to append a scene in blender from a blend file

a guest
Dec 8th, 2014
330
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bl_info = {
  2. "name": "yellowsubmarine",
  3. "author": "anonb",
  4. "version": (1, 0, 0),
  5. "blender": (2, 72, 0),
  6. "location": "Add > Mesh",
  7. "description": "Create yellowsubmarine primitive.",
  8. "warning": "",
  9. "wiki_url": "",
  10. "tracker_url": "",
  11. "category": "Add Mesh"}
  12.  
  13.  
  14. if "bpy" in locals():
  15.        import imp
  16.  
  17.  
  18. import bpy
  19. import bmesh
  20. import math
  21. from mathutils import *
  22.  
  23.  
  24. class OBJECT_OT_addSubmarine(bpy.types.Operator):
  25.     '''
  26.    Class representing an operator for adding a yellow submarine
  27.    '''
  28.     bl_idname = "mesh.addsubmarine" #name used to refer to this operator
  29.     bl_label = "Add Submarine" #operator's label
  30.     bl_options = {'REGISTER', 'UNDO'}
  31.     bl_description = "Add a yellow submarine" #tooltip
  32.    
  33.     def execute(self, context):
  34.         '''
  35.        Function to process a click on the "Add Submarine" button
  36.        '''
  37.         bpy.ops.wm.link_append(directory="C:/Users/Youruser/Desktop/test_append/yellowsubmarine.blend/Scene/",
  38.             filename="Scene", link=False) #append submarine from .blend file
  39.         return{'FINISHED'}
  40.  
  41.  
  42. def menu_item(self, context):
  43.        self.layout.operator(yellowsubmarine.bl_idname, text="yellowsubmarine", icon="PLUGIN")
  44.  
  45. def register():
  46.        bpy.utils.register_module(__name__)
  47.        bpy.types.INFO_MT_mesh_add.append(menu_func)
  48.  
  49. def unregister():
  50.        bpy.utils.unregister_module(__name__)
  51.        bpy.types.INFO_MT_mesh_add.remove(menu_item)
  52.  
  53. if __name__ == "__main__":
  54.        register()
RAW Paste Data