-
-
Save bdancer/21cbf4fd46e687386d61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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