Skip to content

Instantly share code, notes, and snippets.

@bdancer
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdancer/21cbf4fd46e687386d61 to your computer and use it in GitHub Desktop.
Save bdancer/21cbf4fd46e687386d61 to your computer and use it in GitHub Desktop.
bl_info = {
"name": "My Addon",
"category": "3D View"
}
import bpy
class MyOperator(bpy.types.Operator):
bl_idname = "ar1.append"
bl_label = "Array"
count = bpy.props.IntProperty(
name = "Count",
min = 0,
default = 3
)
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def execute(self, context):
ob = context.active_object
if not ob:
return {'CANCELLED'}
bpy.ops.object.modifier_add(type='ARRAY')
ob.modifiers["Array"].count = self.count
return {'FINISHED'}
class MyPanel(bpy.types.Panel):
bl_label = "My Menu"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
def draw(self, context):
layout = self.layout
op = layout.operator("ar1.append")
def register():
bpy.utils.register_class(MyOperator)
bpy.utils.register_class(MyPanel)
def unregister():
bpy.utils.unregister_class(MyOperator)
bpy.utils.unregister_class(MyPanel)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment