diff options
author | meta-androcto <meta.androcto1@gmail.com> | 2017-03-17 06:46:03 +0300 |
---|---|---|
committer | meta-androcto <meta.androcto1@gmail.com> | 2017-03-17 06:46:03 +0300 |
commit | fcf5f2842a836006aa5fb4a0fe037a3ff49fff97 (patch) | |
tree | 336dfe59ca9304b3ab109602562fc246706d6f82 /add_curve_extra_objects/add_curve_braid.py | |
parent | f14b4f40c13285bede9fa3b07f79e45fa4952910 (diff) |
Update add curve extra objects Re: T50943
Diffstat (limited to 'add_curve_extra_objects/add_curve_braid.py')
-rw-r--r-- | add_curve_extra_objects/add_curve_braid.py | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/add_curve_extra_objects/add_curve_braid.py b/add_curve_extra_objects/add_curve_braid.py new file mode 100644 index 00000000..e31033a2 --- /dev/null +++ b/add_curve_extra_objects/add_curve_braid.py @@ -0,0 +1,88 @@ + +import bpy +from bpy.props import (FloatProperty, + FloatVectorProperty, + IntProperty, + BoolProperty, + StringProperty) + +from .bpybraid import awesome_braid, defaultCircle +''' +bl_info = { + "name": "New Braid", + "author": "Jared Forsyth <github.com/jaredly>", + "version": (1, 0), + "blender": (2, 6, 0), + "location": "View3D > Add > Mesh > New Braid", + "description": "Adds a new Braid", + "warning": "", + "wiki_url": "", + "tracker_url": "", + "category": "Add Mesh"} +''' +from bpy.types import Operator + + +class Braid(Operator): + '''Add a Braid''' + bl_idname = 'mesh.add_braid' + bl_label = 'New Braid' + bl_description = 'Create a new braid' + bl_options = {'REGISTER', 'UNDO', 'PRESET'} + + strands = IntProperty(name='strands', min=2, max=100, default=3) + sides = IntProperty(name='sides', min=2, max=100, default=5) + radius = FloatProperty(name='radius', default=1) + thickness = FloatProperty(name='thickness', default=.3) + strandsize = FloatProperty(name='strandsize', default=.3, min=.01, max=10) + width = FloatProperty(name='width', default=.2) + resolution = IntProperty(name='resolution', min=1, default=2, max=100) + pointy = BoolProperty(name='pointy', default=False) + + def execute(self, context): + circle = defaultCircle(self.strandsize) + context.scene.objects.link(circle) + braid = awesome_braid(self.strands, self.sides, + bevel=circle.name, + pointy=self.pointy, + radius=self.radius, + mr=self.thickness, + mz=self.width, + resolution=self.resolution) + base = context.scene.objects.link(braid) + + for ob in context.scene.objects: + ob.select = False + base.select = True + context.scene.objects.active = braid + return {'FINISHED'} + + def draw(self, context): + layout = self.layout + + box = layout.box() + box.prop(self, 'strands') + box.prop(self, 'sides') + box.prop(self, 'radius') + box.prop(self, 'thickness') + box.prop(self, 'strandsize') + box.prop(self, 'width') + box.prop(self, 'resolution') + box.prop(self, 'pointy') + + +def add_object_button(self, context): + self.layout.operator(Braid.bl_idname, text="Add Braid", icon='PLUGIN') + + +def register(): + bpy.utils.register_class(Braid) + bpy.types.INFO_MT_mesh_add.append(add_object_button) + + +def unregister(): + bpy.utils.unregister_class(Braid) + bpy.types.INFO_MT_mesh_add.remove(add_object_button) + +if __name__ == "__main__": + register() |