Guest User

custom 3d menu to append objects in blender

a guest
Dec 7th, 2014
274
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, 65, 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 = "addSubmarineButton" #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/Youuser/Desktop/test_append/yellowsubmarine.blend/Scene/",
  38.             filename="Submarine", link=False) #append submarine from .blend file
  39.         return{'FINISHED'}
  40.  
  41.  
  42. def menu_func(self, context):
  43.     self.layout.operator("addSubmarineButton")
  44.  
  45. def register():
  46.    # bpy.utils.register_module(__name__)
  47.    # this adds your menu to shift-a add menu
  48.    bpy.types.INFO_MT_add.prepend(menu_func)
  49.  
  50. def unregister():
  51.     # bpy.utils.unregister_module(__name__)
  52.     bpy.types.INFO_MT_add.remove(menu_func)
  53.  
  54. if __name__ == "__main__":
  55.     register()
RAW Paste Data