Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # ##### BEGIN GPL LICENSE BLOCK #####
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. #
  19. # ##### END GPL LICENSE BLOCK #####
  20.  
  21. bl_info = {
  22. "name": "Addon Courbes libres",
  23. "author": "Laurent Laget",
  24. "version": (0, 4, 2),
  25. "blender": (2, 78, 0),
  26. "location": "Add",
  27. "description": "Dessine en courbes libres 3D",
  28. "warning": "",
  29. "wiki_url": "",
  30. "category": "Add",
  31. }
  32.  
  33. import bpy
  34.  
  35. #classe dessin de courbes
  36. class dessin(bpy.types.Operator):
  37. """Dessiner sans avoir à créer de curve"""
  38. bl_idname = "object.dessin"
  39. bl_label = "dessin"
  40. bl_options = {'REGISTER', 'UNDO'}
  41.  
  42. def execute(self, context):
  43. bpy.ops.curve.primitive_bezier_curve_add()
  44. bpy.ops.object.editmode_toggle()
  45. bpy.ops.curve.delete(type='VERT')
  46. bpy.context.object.data.fill_mode = 'FULL'
  47. bpy.context.object.data.bevel_resolution = 3
  48. bpy.context.object.data.bevel_depth = 0.3
  49. return {'FINISHED'}
  50.  
  51. addon_keymaps = []
  52.  
  53. def menu_item(self, context):
  54. self.layout.operator(dessin.bl_idname, text="Courbe libre", icon="PLUGIN")
  55.  
  56.  
  57. def register():
  58. bpy.utils.register_module(__name__)
  59. #bpy.utils.register_class(dessin)
  60.  
  61.  
  62. bpy.types.INFO_MT_curve_add.append(menu_item)
  63.  
  64. global addon_keymaps
  65. wm = bpy.context.window_manager
  66. km = wm.keyconfigs.addon.keymaps.new(name = "3D View", space_type = "VIEW_3D")
  67. kmi = km.keymap_items.new(dessin.bl_idname, 'SELECTMOUSE', 'CLICK', shift=True,alt=True)
  68.  
  69. addon_keymaps.append(km)
  70.  
  71.  
  72. def unregister():
  73. bpy.utils.unregister_class(dessin)
  74. bpy.utils.unregister_module(__name__)
  75. bpy.types.INFO_MT_curve_add.remove(menu_item)
  76.  
  77. global addon_keymaps
  78. wm = bpy.context.window_manager
  79. for km in addon_keymaps:
  80. for kmi in km.keymap_items:
  81. km.keymap_items.remove(kmi)
  82. wm.keyconfigs.addon.keymaps.remove(km)
  83. addon_keymaps.clear()
  84.  
  85.  
  86. if __name__ == "__main__":
  87. register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement