Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2018-12-19 03:35:52 +0300
committerSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2018-12-19 03:35:52 +0300
commit156c5ea6a45d0549d8422e3ea295972dec7766c3 (patch)
tree6966bff1fed7789294f93ce953aa852fc55cb277 /add_curve_extra_objects/add_curve_simple.py
parentbf867f50228505710c51eb7d76832415c36d9f74 (diff)
Update addon to Blender 2.8
Diffstat (limited to 'add_curve_extra_objects/add_curve_simple.py')
-rw-r--r--add_curve_extra_objects/add_curve_simple.py627
1 files changed, 129 insertions, 498 deletions
diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py
index cdf91717..0d4b9224 100644
--- a/add_curve_extra_objects/add_curve_simple.py
+++ b/add_curve_extra_objects/add_curve_simple.py
@@ -19,8 +19,8 @@
bl_info = {
"name": "Simple Curve",
"author": "Spivak Vladimir (http://cwolf3d.korostyshev.net)",
- "version": (1, 5, 3),
- "blender": (2, 6, 9),
+ "version": (1, 5, 4),
+ "blender": (2, 80, 0),
"location": "View3D > Add > Curve",
"description": "Adds Simple Curve",
"warning": "",
@@ -388,7 +388,7 @@ def align_matrix(context, location):
rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4()
else:
rot = Matrix()
- align_matrix = loc * rot
+ align_matrix = loc @ rot
return align_matrix
@@ -397,19 +397,30 @@ def align_matrix(context, location):
# Main Function
def main(context, self, align_matrix):
- # deselect all objects
- bpy.ops.object.select_all(action='DESELECT')
-
# create object
- name = self.Simple_Type # Type as name
-
- # create curve
scene = bpy.context.scene
- newCurve = bpy.data.curves.new(name, type='CURVE') # curvedatablock
- newSpline = newCurve.splines.new('BEZIER') # spline
+
+ if bpy.context.mode == 'EDIT_CURVE':
+ newCurve = context.active_object.data
+ newSpline = newCurve.splines.new('BEZIER') # spline
+ else:
+ name = self.Simple_Type # Type as name
+ # create curve
+
+ newCurve = bpy.data.curves.new(name, type='CURVE') # curvedatablock
+ newSpline = newCurve.splines.new('BEZIER') # spline
+
+ # set curveOptions
+ newCurve.dimensions = self.shape
+
+ # create object with newCurve
+ SimpleCurve = bpy.data.objects.new(name, newCurve) # object
+ scene.collection.objects.link(SimpleCurve) # place in active scene
+ SimpleCurve.select_set(True)
+ SimpleCurve.matrix_world = align_matrix # apply matrix
+ SimpleCurve.rotation_euler = self.Simple_rotation_euler
- # set curveOptions
- newCurve.dimensions = self.shape
+
newSpline.use_endpoint_u = True
sides = abs(int((self.Simple_endangle - self.Simple_startangle) / 90))
@@ -525,14 +536,6 @@ def main(context, self, align_matrix):
newSpline.bezier_points.add(int(len(vertArray) * 0.333333333))
newSpline.bezier_points.foreach_set('co', vertArray)
- # create object with newCurve
- SimpleCurve = bpy.data.objects.new(name, newCurve) # object
- scene.objects.link(SimpleCurve) # place in active scene
- SimpleCurve.select = True # set as selected
- scene.objects.active = SimpleCurve # set as active
- SimpleCurve.matrix_world = align_matrix # apply matrix
- SimpleCurve.rotation_euler = self.Simple_rotation_euler
-
all_points = [p for p in newSpline.bezier_points]
d = 2 * 0.27606262
n = 0
@@ -761,45 +764,73 @@ def main(context, self, align_matrix):
all_points[int(n / 2) - 1].handle_right_type = 'VECTOR'
all_points[int(n / 2)].handle_left_type = 'VECTOR'
- SimpleCurve.s_curve.Simple = True
- SimpleCurve.s_curve.Simple_Change = False
- SimpleCurve.s_curve.Simple_Type = self.Simple_Type
- SimpleCurve.s_curve.Simple_startlocation = self.Simple_startlocation
- SimpleCurve.s_curve.Simple_endlocation = self.Simple_endlocation
- SimpleCurve.s_curve.Simple_a = self.Simple_a
- SimpleCurve.s_curve.Simple_b = self.Simple_b
- SimpleCurve.s_curve.Simple_h = self.Simple_h
- SimpleCurve.s_curve.Simple_angle = self.Simple_angle
- SimpleCurve.s_curve.Simple_startangle = self.Simple_startangle
- SimpleCurve.s_curve.Simple_endangle = self.Simple_endangle
- SimpleCurve.s_curve.Simple_rotation_euler = self.Simple_rotation_euler
- SimpleCurve.s_curve.Simple_sides = self.Simple_sides
- SimpleCurve.s_curve.Simple_radius = self.Simple_radius
- SimpleCurve.s_curve.Simple_center = self.Simple_center
- SimpleCurve.s_curve.Simple_width = self.Simple_width
- SimpleCurve.s_curve.Simple_length = self.Simple_length
- SimpleCurve.s_curve.Simple_rounded = self.Simple_rounded
-
- bpy.ops.object.mode_set(mode='EDIT', toggle=True)
- bpy.ops.curve.select_all(action='SELECT')
- bpy.ops.object.mode_set(mode='OBJECT', toggle=True)
-
return
+# ### MENU append ###
+def Simple_curve_edit_menu(self, context):
+ bl_label = 'Simple edit'
+
+ self.layout.operator("curve.bezier_points_fillet", text="Fillet")
+ self.layout.operator("curve.bezier_spline_divide", text="Divide")
+ self.layout.separator()
-# ------------------------------------------------------------
-# Delete simple curve
+def menu(self, context):
+ oper1 = self.layout.operator(Simple.bl_idname, text="Angle", icon="MOD_CURVE")
+ oper1.Simple_Change = False
+ oper1.Simple_Type = "Angle"
-def SimpleDelete(name):
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='OBJECT')
+ oper2 = self.layout.operator(Simple.bl_idname, text="Arc", icon="MOD_CURVE")
+ oper2.Simple_Change = False
+ oper2.Simple_Type = "Arc"
- bpy.context.scene.objects.active = bpy.data.objects[name]
- bpy.ops.object.delete()
+ oper3 = self.layout.operator(Simple.bl_idname, text="Circle", icon="MOD_CURVE")
+ oper3.Simple_Change = False
+ oper3.Simple_Type = "Circle"
- return
+ oper4 = self.layout.operator(Simple.bl_idname, text="Distance", icon="MOD_CURVE")
+ oper4.Simple_Change = False
+ oper4.Simple_Type = "Distance"
+
+ oper5 = self.layout.operator(Simple.bl_idname, text="Ellipse", icon="MOD_CURVE")
+ oper5.Simple_Change = False
+ oper5.Simple_Type = "Ellipse"
+ oper6 = self.layout.operator(Simple.bl_idname, text="Line", icon="MOD_CURVE")
+ oper6.Simple_Change = False
+ oper6.Simple_Type = "Line"
+ oper7 = self.layout.operator(Simple.bl_idname, text="Point", icon="MOD_CURVE")
+ oper7.Simple_Change = False
+ oper7.Simple_Type = "Point"
+
+ oper8 = self.layout.operator(Simple.bl_idname, text="Polygon", icon="MOD_CURVE")
+ oper8.Simple_Change = False
+ oper8.Simple_Type = "Polygon"
+
+ oper9 = self.layout.operator(Simple.bl_idname, text="Polygon ab", icon="MOD_CURVE")
+ oper9.Simple_Change = False
+ oper9.Simple_Type = "Polygon_ab"
+
+ oper10 = self.layout.operator(Simple.bl_idname, text="Rectangle", icon="MOD_CURVE")
+ oper10.Simple_Change = False
+ oper10.Simple_Type = "Rectangle"
+
+ oper11 = self.layout.operator(Simple.bl_idname, text="Rhomb", icon="MOD_CURVE")
+ oper11.Simple_Change = False
+ oper11.Simple_Type = "Rhomb"
+
+ oper12 = self.layout.operator(Simple.bl_idname, text="Sector", icon="MOD_CURVE")
+ oper12.Simple_Change = False
+ oper12.Simple_Type = "Sector"
+
+ oper13 = self.layout.operator(Simple.bl_idname, text="Segment", icon="MOD_CURVE")
+ oper13.Simple_Change = False
+ oper13.Simple_Type = "Segment"
+
+ oper14 = self.layout.operator(Simple.bl_idname, text="Trapezoid", icon="MOD_CURVE")
+ oper14.Simple_Change = False
+ oper14.Simple_Type = "Trapezoid"
+
# ------------------------------------------------------------
# Simple operator
@@ -810,20 +841,20 @@ class Simple(Operator):
bl_options = {'REGISTER', 'UNDO'}
# align_matrix for the invoke
- align_matrix = Matrix()
+ align_matrix : Matrix()
# change properties
- Simple = BoolProperty(
+ Simple : BoolProperty(
name="Simple",
default=True,
description="Simple Curve"
)
- Simple_Change = BoolProperty(
+ Simple_Change : BoolProperty(
name="Change",
default=False,
description="Change Simple Curve"
)
- Simple_Delete = StringProperty(
+ Simple_Delete : StringProperty(
name="Delete",
description="Delete Simple Curve"
)
@@ -843,84 +874,84 @@ class Simple(Operator):
('Polygon_ab', "Polygon ab", "Construct a Polygon ab"),
('Trapezoid', "Trapezoid", "Construct a Trapezoid")
]
- Simple_Type = EnumProperty(
+ Simple_Type : EnumProperty(
name="Type",
description="Form of Curve to create",
items=Types
)
# Line properties
- Simple_startlocation = FloatVectorProperty(
+ Simple_startlocation : FloatVectorProperty(
name="",
description="Start location",
default=(0.0, 0.0, 0.0),
subtype='TRANSLATION'
)
- Simple_endlocation = FloatVectorProperty(
+ Simple_endlocation : FloatVectorProperty(
name="",
description="End location",
default=(2.0, 2.0, 2.0),
subtype='TRANSLATION'
)
- Simple_rotation_euler = FloatVectorProperty(
+ Simple_rotation_euler : FloatVectorProperty(
name="",
description="Rotation",
default=(0.0, 0.0, 0.0),
subtype='EULER'
)
# Trapezoid properties
- Simple_a = FloatProperty(
+ Simple_a : FloatProperty(
name="Side a",
default=2.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="a side Value"
)
- Simple_b = FloatProperty(
+ Simple_b : FloatProperty(
name="Side b",
default=1.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="b side Value"
)
- Simple_h = FloatProperty(
+ Simple_h : FloatProperty(
name="Height",
default=1.0,
unit='LENGTH',
description="Height of the Trapezoid - distance between a and b"
)
- Simple_angle = FloatProperty(
+ Simple_angle : FloatProperty(
name="Angle",
default=45.0,
description="Angle"
)
- Simple_startangle = FloatProperty(
+ Simple_startangle : FloatProperty(
name="Start angle",
default=0.0,
min=-360.0, soft_min=-360.0,
max=360.0, soft_max=360.0,
description="Start angle"
)
- Simple_endangle = FloatProperty(
+ Simple_endangle : FloatProperty(
name="End angle",
default=45.0,
min=-360.0, soft_min=-360.0,
max=360.0, soft_max=360.0,
description="End angle"
)
- Simple_sides = IntProperty(
+ Simple_sides : IntProperty(
name="Sides",
default=3,
min=0, soft_min=0,
description="Sides"
)
- Simple_radius = FloatProperty(
+ Simple_radius : FloatProperty(
name="Radius",
default=1.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="Radius"
)
- Simple_center = BoolProperty(
+ Simple_center : BoolProperty(
name="Length center",
default=True,
description="Length center"
@@ -928,27 +959,27 @@ class Simple(Operator):
Angle_types = [('Degrees', "Degrees", "Use Degrees"),
('Radians', "Radians", "Use Radians")]
- Simple_degrees_or_radians = EnumProperty(
+ Simple_degrees_or_radians : EnumProperty(
name="Degrees or radians",
description="Degrees or radians",
items=Angle_types
)
# Rectangle properties
- Simple_width = FloatProperty(
+ Simple_width : FloatProperty(
name="Width",
default=2.0,
min=0.0, soft_min=0,
unit='LENGTH',
description="Width"
)
- Simple_length = FloatProperty(
+ Simple_length : FloatProperty(
name="Length",
default=2.0,
min=0.0, soft_min=0.0,
unit='LENGTH',
description="Length"
)
- Simple_rounded = FloatProperty(
+ Simple_rounded : FloatProperty(
name="Rounded",
default=0.0,
min=0.0, soft_min=0.0,
@@ -959,7 +990,7 @@ class Simple(Operator):
shapeItems = [
('2D', "2D", "2D shape Curve"),
('3D', "3D", "3D shape Curve")]
- shape = EnumProperty(
+ shape : EnumProperty(
name="2D / 3D",
items=shapeItems,
description="2D or 3D Curve"
@@ -1140,10 +1171,10 @@ class Simple(Operator):
row = layout.row()
row.prop(self, "shape", expand=True)
box = layout.box()
- box.label("Location:")
+ box.label(text="Location:")
box.prop(self, "Simple_startlocation")
box = layout.box()
- box.label("Rotation:")
+ box.label(text="Rotation:")
box.prop(self, "Simple_rotation_euler")
if l != 0 or s != 0:
@@ -1151,49 +1182,22 @@ class Simple(Operator):
box.label(text="Statistics:", icon="INFO")
if l != 0:
l_str = str(round(l, 4))
- box.label("Length: " + l_str)
+ box.label(text="Length: " + l_str)
if s != 0:
s_str = str(round(s, 4))
- box.label("Area: " + s_str)
+ box.label(text="Area: " + s_str)
@classmethod
def poll(cls, context):
return context.scene is not None
def execute(self, context):
- if self.Simple_Change:
- SimpleDelete(self.Simple_Delete)
-
- # go to object mode
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='OBJECT')
-
- # turn off undo
- undo = bpy.context.user_preferences.edit.use_global_undo
- bpy.context.user_preferences.edit.use_global_undo = False
-
# main function
self.align_matrix = align_matrix(context, self.Simple_startlocation)
main(context, self, self.align_matrix)
- # restore pre operator undo state
- bpy.context.user_preferences.edit.use_global_undo = undo
-
- return {'FINISHED'}
-
- def invoke(self, context, event):
- # store creation_matrix
- if self.Simple_Change:
- bpy.context.scene.cursor_location = self.Simple_startlocation
- else:
- self.Simple_startlocation = bpy.context.scene.cursor_location
-
- self.align_matrix = align_matrix(context, self.Simple_startlocation)
- self.execute(context)
-
return {'FINISHED'}
-
# ------------------------------------------------------------
# Fillet
@@ -1201,9 +1205,9 @@ class BezierPointsFillet(Operator):
bl_idname = "curve.bezier_points_fillet"
bl_label = "Bezier points Fillet"
bl_description = "Bezier points Fillet"
- bl_options = {'REGISTER', 'UNDO'}
+ bl_options = {'REGISTER', 'UNDO', 'PRESET'}
- Fillet_radius = FloatProperty(
+ Fillet_radius : FloatProperty(
name="Radius",
default=0.25,
unit='LENGTH',
@@ -1211,7 +1215,7 @@ class BezierPointsFillet(Operator):
)
Types = [('Round', "Round", "Round"),
('Chamfer', "Chamfer", "Chamfer")]
- Fillet_Type = EnumProperty(
+ Fillet_Type : EnumProperty(
name="Type",
description="Fillet type",
items=Types
@@ -1230,15 +1234,6 @@ class BezierPointsFillet(Operator):
return context.scene is not None
def execute(self, context):
- # go to object mode
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.mode_set(mode='EDIT')
-
- # turn off undo
- undo = bpy.context.user_preferences.edit.use_global_undo
- bpy.context.user_preferences.edit.use_global_undo = False
-
# main function
spline = bpy.context.object.data.splines.active
selected = [p for p in spline.bezier_points if p.select_control_point]
@@ -1321,17 +1316,8 @@ class BezierPointsFillet(Operator):
bpy.ops.curve.select_all(action='SELECT')
bpy.ops.curve.spline_type_set(type='BEZIER')
- # restore pre operator undo state
- bpy.context.user_preferences.edit.use_global_undo = undo
-
return {'FINISHED'}
- def invoke(self, context, event):
- self.execute(context)
-
- return {'FINISHED'}
-
-
def subdivide_cubic_bezier(p1, p2, p3, p4, t):
p12 = (p2 - p1) * t + p1
p23 = (p3 - p2) * t + p2
@@ -1352,9 +1338,9 @@ class BezierDivide(Operator):
bl_options = {'REGISTER', 'UNDO'}
# align_matrix for the invoke
- align_matrix = Matrix()
+ align_matrix : Matrix()
- Bezier_t = FloatProperty(
+ Bezier_t : FloatProperty(
name="t (0% - 100%)",
default=50.0,
min=0.0, soft_min=0.0,
@@ -1367,15 +1353,6 @@ class BezierDivide(Operator):
return context.scene is not None
def execute(self, context):
- # go to object mode
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='OBJECT')
- bpy.ops.object.mode_set(mode='EDIT')
-
- # turn off undo
- undo = bpy.context.user_preferences.edit.use_global_undo
- bpy.context.user_preferences.edit.use_global_undo = False
-
# main function
spline = bpy.context.object.data.splines.active
selected_all = [p for p in spline.bezier_points if p.select_control_point]
@@ -1414,376 +1391,30 @@ class BezierDivide(Operator):
selected_all[2].handle_right = h[3]
selected_all[0].handle_left = h[4]
- # restore pre operator undo state
- bpy.context.user_preferences.edit.use_global_undo = undo
-
return {'FINISHED'}
- def invoke(self, context, event):
- self.execute(context)
-
- return {'FINISHED'}
-
-
-# ------------------------------------------------------------
-# Simple change panel
-
-class SimplePanel(Panel):
- bl_idname = "VIEW3D_PT_simple_curve"
- bl_label = "Simple Curve"
- bl_space_type = "VIEW_3D"
- bl_region_type = "TOOLS"
- bl_options = {'DEFAULT_CLOSED'}
- bl_category = "Tools"
-
- @classmethod
- def poll(cls, context):
- if not context.active_object:
- pass
- elif context.object.s_curve.Simple is True:
- return (context.object)
-
- def draw(self, context):
- if context.object.s_curve.Simple is True:
- layout = self.layout
- obj = context.object
- row = layout.row()
-
- simple_change = row.operator("curve.simple", text="Change",
- icon="OUTLINER_DATA_CURVE")
- simple_change.Simple_Change = True
- simple_change.Simple_Delete = obj.name
- simple_change.Simple_Type = obj.s_curve.Simple_Type
- simple_change.Simple_startlocation = obj.location
- simple_change.Simple_endlocation = obj.s_curve.Simple_endlocation
-
- simple_change.Simple_a = obj.s_curve.Simple_a
- simple_change.Simple_b = obj.s_curve.Simple_b
- simple_change.Simple_h = obj.s_curve.Simple_h
-
- simple_change.Simple_angle = obj.s_curve.Simple_angle
- simple_change.Simple_startangle = obj.s_curve.Simple_startangle
- simple_change.Simple_endangle = obj.s_curve.Simple_endangle
- simple_change.Simple_rotation_euler = obj.rotation_euler
-
- simple_change.Simple_sides = obj.s_curve.Simple_sides
- simple_change.Simple_radius = obj.s_curve.Simple_radius
- simple_change.Simple_center = obj.s_curve.Simple_center
- simple_change.Simple_width = obj.s_curve.Simple_width
- simple_change.Simple_length = obj.s_curve.Simple_length
- simple_change.Simple_rounded = obj.s_curve.Simple_rounded
-
-
-# ------------------------------------------------------------
-# Fillet tools panel
-
-class SimpleEdit(Operator):
- bl_idname = "object._simple_edit"
- bl_label = "Create Curves"
- bl_description = "Subdivide and Fillet Curves"
- bl_options = {'REGISTER', 'UNDO'}
-
- @classmethod
- def poll(cls, context):
- vertex = []
- nselected = []
- n = 0
- obj = context.active_object
- if obj is not None:
- if obj.type == 'CURVE':
- for i in obj.data.splines:
- for j in i.bezier_points:
- n += 1
- if j.select_control_point:
- nselected.append(n)
- vertex.append(obj.matrix_world * j.co)
-
- if len(vertex) > 0 and n > 2:
- return (context.active_object)
- if len(vertex) == 2 and abs(nselected[0] - nselected[1]) == 1:
- return (context.active_object)
-
- selected = 0
- for obj in context.selected_objects:
- if obj.type == 'CURVE':
- selected += 1
-
- if selected >= 2:
- return (context.selected_objects)
-
- def draw(self, context):
- vertex = []
- selected = []
- n = 0
- obj = context.active_object
- if obj is not None:
- if obj.type == 'CURVE':
- for i in obj.data.splines:
- for j in i.bezier_points:
- n += 1
- if j.select_control_point:
- selected.append(n)
- vertex.append(obj.matrix_world * j.co)
-
- if len(vertex) > 0 and n > 2:
- layout = self.layout
- row = layout.row()
- row.operator("curve.bezier_points_fillet", text="Fillet")
-
- if len(vertex) == 2 and abs(selected[0] - selected[1]) == 1:
- layout = self.layout
- row = layout.row()
- row.operator("curve.bezier_spline_divide", text="Divide")
-
-
-# ------------------------------------------------------------
-# location update
-
-def StartLocationUpdate(self, context):
-
- bpy.context.scene.cursor_location = self.Simple_startlocation
- return
-
-
-# ------------------------------------------------------------
-# Add properties to objects
-
-class SimpleVariables(PropertyGroup):
-
- Simple = BoolProperty()
- Simple_Change = BoolProperty()
-
- # general properties
- Types = [('Point', "Point", "Construct a Point"),
- ('Line', "Line", "Construct a Line"),
- ('Distance', "Distance", "Construct a two point Distance"),
- ('Angle', "Angle", "Construct an Angle"),
- ('Circle', "Circle", "Construct a Circle"),
- ('Ellipse', "Ellipse", "Construct an Ellipse"),
- ('Arc', "Arc", "Construct an Arc"),
- ('Sector', "Sector", "Construct a Sector"),
- ('Segment', "Segment", "Construct a Segment"),
- ('Rectangle', "Rectangle", "Construct a Rectangle"),
- ('Rhomb', "Rhomb", "Construct a Rhomb"),
- ('Polygon', "Polygon", "Construct a Polygon"),
- ('Polygon_ab', "Polygon ab", "Construct a Polygon ab"),
- ('Trapezoid', "Trapezoid", "Construct a Trapezoid")
- ]
- Simple_Type = EnumProperty(
- name="Type",
- description="Form of Curve to create",
- items=Types
- )
- # Line properties
- Simple_startlocation = FloatVectorProperty(
- name="Start location",
- description="Start location",
- default=(0.0, 0.0, 0.0),
- subtype='TRANSLATION',
- update=StartLocationUpdate
- )
- Simple_endlocation = FloatVectorProperty(
- name="End location",
- description="End location",
- default=(2.0, 2.0, 2.0),
- subtype='TRANSLATION'
- )
- Simple_rotation_euler = FloatVectorProperty(
- name="Rotation",
- description="Rotation",
- default=(0.0, 0.0, 0.0),
- subtype='EULER'
- )
- # Trapezoid properties
- Simple_a = FloatProperty(
- name="Side a",
- default=2.0,
- min=0.0, soft_min=0.0,
- unit='LENGTH',
- description="a side Value"
- )
- Simple_b = FloatProperty(
- name="Side b",
- default=1.0,
- min=0.0, soft_min=0.0,
- unit='LENGTH',
- description="b side Value"
- )
- Simple_h = FloatProperty(
- name="Height",
- default=1.0,
- unit='LENGTH',
- description="Height of the Trapezoid - distance between a and b"
- )
- Simple_angle = FloatProperty(
- name="Angle",
- default=45.0,
- description="Angle"
- )
- Simple_startangle = FloatProperty(
- name="Start angle",
- default=0.0,
- min=-360.0, soft_min=-360.0,
- max=360.0, soft_max=360.0,
- description="Start angle"
- )
- Simple_endangle = FloatProperty(
- name="End angle",
- default=45.0,
- min=-360.0, soft_min=-360.0,
- max=360.0, soft_max=360.0,
- description="End angle"
- )
- Simple_sides = IntProperty(
- name="Sides",
- default=3,
- min=3, soft_min=3,
- description="Number of Sides"
- )
- Simple_radius = FloatProperty(
- name="Radius",
- default=1.0,
- min=0.0, soft_min=0.0,
- unit='LENGTH',
- description="Radius"
- )
- Simple_center = BoolProperty(
- name="Length center",
- default=True,
- description="Length center"
- )
- # Rectangle properties
- Simple_width = FloatProperty(
- name="Width",
- default=2.0,
- min=0.0, soft_min=0.0,
- unit='LENGTH',
- description="Width"
- )
- Simple_length = FloatProperty(
- name="Length",
- default=2.0,
- min=0.0, soft_min=0.0,
- unit='LENGTH',
- description="Length"
- )
- Simple_rounded = FloatProperty(
- name="Rounded",
- default=0.0,
- unit='LENGTH',
- description="Rounded corners"
- )
-
-
-class VIEW3D_MT_simple_menu(Menu):
- bl_idname = "VIEW3D_MT_simple_menu"
- bl_label = "2D Objects"
-
- def draw(self, context):
- self.layout.operator_context = 'INVOKE_REGION_WIN'
-
- oper1 = self.layout.operator(Simple.bl_idname, text="Angle", icon="MOD_CURVE")
- oper1.Simple_Change = False
- oper1.Simple_Type = "Angle"
-
- oper2 = self.layout.operator(Simple.bl_idname, text="Arc", icon="MOD_CURVE")
- oper2.Simple_Change = False
- oper2.Simple_Type = "Arc"
-
- oper3 = self.layout.operator(Simple.bl_idname, text="Circle", icon="MOD_CURVE")
- oper3.Simple_Change = False
- oper3.Simple_Type = "Circle"
-
- oper4 = self.layout.operator(Simple.bl_idname, text="Distance", icon="MOD_CURVE")
- oper4.Simple_Change = False
- oper4.Simple_Type = "Distance"
-
- oper5 = self.layout.operator(Simple.bl_idname, text="Ellipse", icon="MOD_CURVE")
- oper5.Simple_Change = False
- oper5.Simple_Type = "Ellipse"
-
- oper6 = self.layout.operator(Simple.bl_idname, text="Line", icon="MOD_CURVE")
- oper6.Simple_Change = False
- oper6.Simple_Type = "Line"
-
- oper7 = self.layout.operator(Simple.bl_idname, text="Point", icon="MOD_CURVE")
- oper7.Simple_Change = False
- oper7.Simple_Type = "Point"
-
- oper8 = self.layout.operator(Simple.bl_idname, text="Polygon", icon="MOD_CURVE")
- oper8.Simple_Change = False
- oper8.Simple_Type = "Polygon"
-
- oper9 = self.layout.operator(Simple.bl_idname, text="Polygon ab", icon="MOD_CURVE")
- oper9.Simple_Change = False
- oper9.Simple_Type = "Polygon_ab"
-
- oper10 = self.layout.operator(Simple.bl_idname, text="Rectangle", icon="MOD_CURVE")
- oper10.Simple_Change = False
- oper10.Simple_Type = "Rectangle"
-
- oper11 = self.layout.operator(Simple.bl_idname, text="Rhomb", icon="MOD_CURVE")
- oper11.Simple_Change = False
- oper11.Simple_Type = "Rhomb"
-
- oper12 = self.layout.operator(Simple.bl_idname, text="Sector", icon="MOD_CURVE")
- oper12.Simple_Change = False
- oper12.Simple_Type = "Sector"
-
- oper13 = self.layout.operator(Simple.bl_idname, text="Segment", icon="MOD_CURVE")
- oper13.Simple_Change = False
- oper13.Simple_Type = "Segment"
-
- oper14 = self.layout.operator(Simple.bl_idname, text="Trapezoid", icon="MOD_CURVE")
- oper14.Simple_Change = False
- oper14.Simple_Type = "Trapezoid"
-
-
# Register
-
-def Simple_button(self, context):
- layout = self.layout
- layout.separator()
- self.layout.menu("VIEW3D_MT_simple_menu", icon="MOD_CURVE")
-
-class VIEW3D_MT_simple_edit_curve_menu(bpy.types.Menu):
- bl_label = 'Simple edit'
-
- def draw(self, context):
- self.layout.operator("curve.bezier_points_fillet", text="Fillet")
- self.layout.operator("curve.bezier_spline_divide", text="Divide")
-
-def Simple_curve_edit_menu(self, context):
- self.layout.menu('VIEW3D_MT_simple_edit_curve_menu')
- self.layout.separator()
+classes = [
+ Simple,
+ BezierDivide,
+ BezierPointsFillet
+]
def register():
- bpy.utils.register_class(Simple)
- bpy.utils.register_class(BezierPointsFillet)
- bpy.utils.register_class(BezierDivide)
- bpy.utils.register_class(SimplePanel)
- bpy.utils.register_class(SimpleEdit)
- bpy.utils.register_class(VIEW3D_MT_simple_menu)
- bpy.utils.register_class(SimpleVariables)
-
- bpy.types.VIEW3D_MT_curve_add.append(Simple_button)
- bpy.types.VIEW3D_MT_edit_curve_specials.prepend(Simple_curve_edit_menu)
-
- bpy.types.Object.s_curve = PointerProperty(type=SimpleVariables)
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
+ bpy.types.VIEW3D_MT_curve_add.append(menu)
+ bpy.types.VIEW3D_MT_edit_curve_specials.prepend(Simple_curve_edit_menu)
def unregister():
- bpy.utils.unregister_class(Simple)
- bpy.utils.unregister_class(BezierPointsFillet)
- bpy.utils.unregister_class(BezierDivide)
- bpy.utils.unregister_class(SimplePanel)
- bpy.utils.unregister_class(SimpleEdit)
- bpy.utils.unregister_class(VIEW3D_MT_simple_menu)
- bpy.utils.unregister_class(SimpleVariables)
-
- bpy.types.VIEW3D_MT_curve_add.remove(Simple_button)
- del bpy.types.Object.s_curve
+ from bpy.utils import unregister_class
+ for cls in reversed(classes):
+ unregister_class(cls)
+ bpy.types.VIEW3D_MT_curve_add.remove(menu)
+ bpy.types.VIEW3D_MT_edit_curve_specials.remove(Simple_curve_edit_menu)
if __name__ == "__main__":
register()