[Bf-extensions-cvs] [3c317405] master: Moved operator Fillet, Divide, Scale reset in to addon Curve Tools
Spivak Vladimir cwolf3d
noreply at git.blender.org
Sat Sep 14 19:03:34 CEST 2019
Commit: 3c3174056501789f3a0d0697c6b614ceae7f336c
Author: Spivak Vladimir (cwolf3d)
Date: Sat Sep 14 19:56:17 2019 +0300
Branches: master
https://developer.blender.org/rBA3c3174056501789f3a0d0697c6b614ceae7f336c
Moved operator Fillet, Divide, Scale reset in to addon Curve Tools
===================================================================
M add_curve_extra_objects/add_curve_simple.py
===================================================================
diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py
index 65685043..129f66bf 100644
--- a/add_curve_extra_objects/add_curve_simple.py
+++ b/add_curve_extra_objects/add_curve_simple.py
@@ -810,21 +810,6 @@ def main(context, self, align_matrix, use_enter_edit_mode):
else:
Curve.data.fill_mode = 'BOTH'
-# ### 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()
-
-def Simple_curve_object_menu(self, context):
- bl_label = 'Simple edit'
-
- if context.active_object.type == "CURVE":
- self.layout.operator("curve.scale_reset", text="Scale Reset")
- self.layout.separator()
-
def menu(self, context):
oper1 = self.layout.operator(Simple.bl_idname, text="Angle", icon="MOD_CURVE")
oper1.Simple_Type = "Angle"
@@ -1309,285 +1294,9 @@ class Simple(Operator, object_utils.AddObjectHelper):
return {'FINISHED'}
-# ------------------------------------------------------------
-# Fillet
-
-class BezierPointsFillet(Operator):
- bl_idname = "curve.bezier_points_fillet"
- bl_label = "Bezier points Fillet"
- bl_description = "Bezier points Fillet"
- bl_options = {'REGISTER', 'UNDO', 'PRESET'}
-
- Fillet_radius : FloatProperty(
- name="Radius",
- default=0.25,
- unit='LENGTH',
- description="Radius"
- )
- Types = [('Round', "Round", "Round"),
- ('Chamfer', "Chamfer", "Chamfer")]
- Fillet_Type : EnumProperty(
- name="Type",
- description="Fillet type",
- items=Types
- )
-
- def draw(self, context):
- layout = self.layout
-
- # general options
- col = layout.column()
- col.prop(self, "Fillet_radius")
- col.prop(self, "Fillet_Type", expand=True)
-
- @classmethod
- def poll(cls, context):
- return (context.object is not None and
- context.object.type == 'CURVE')
-
- def execute(self, context):
- # main function
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='EDIT')
-
- splines = bpy.context.object.data.splines
- bpy.ops.curve.spline_type_set(type='BEZIER')
-
- bpy.ops.curve.handle_type_set(type='VECTOR')
- s = []
- for spline in splines:
- n = 0
- ii = []
- for p in spline.bezier_points:
- if p.select_control_point:
- ii.append(n)
- n += 1
- else:
- n += 1
- s.append(ii)
-
- sn = 0
- for spline in splines:
- ii = s[sn]
- n = len(spline.bezier_points)
- if n > 2:
- jn = 0
- for j in ii:
-
- j += jn
-
- selected_all = [p for p in spline.bezier_points]
-
- bpy.ops.curve.select_all(action='DESELECT')
-
- if j != 0 and j != n - 1:
- selected_all[j].select_control_point = True
- selected_all[j + 1].select_control_point = True
- bpy.ops.curve.subdivide()
- selected_all = [p for p in spline.bezier_points]
- selected4 = [selected_all[j - 1], selected_all[j],
- selected_all[j + 1], selected_all[j + 2]]
- jn += 1
- n += 1
-
- elif j == 0:
- selected_all[j].select_control_point = True
- selected_all[j + 1].select_control_point = True
- bpy.ops.curve.subdivide()
- selected_all = [p for p in spline.bezier_points]
- selected4 = [selected_all[n], selected_all[0],
- selected_all[1], selected_all[2]]
- jn += 1
- n += 1
-
- elif j == n - 1:
- selected_all[j].select_control_point = True
- selected_all[j - 1].select_control_point = True
- bpy.ops.curve.subdivide()
- selected_all = [p for p in spline.bezier_points]
- selected4 = [selected_all[0], selected_all[n],
- selected_all[n - 1], selected_all[n - 2]]
-
- selected4[2].co = selected4[1].co
- s1 = Vector(selected4[0].co) - Vector(selected4[1].co)
- s2 = Vector(selected4[3].co) - Vector(selected4[2].co)
- s1.normalize()
- s11 = Vector(selected4[1].co) + s1 * self.Fillet_radius
- selected4[1].co = s11
- s2.normalize()
- s22 = Vector(selected4[2].co) + s2 * self.Fillet_radius
- selected4[2].co = s22
-
- if self.Fillet_Type == 'Round':
- if j != n - 1:
- selected4[2].handle_right_type = 'VECTOR'
- selected4[1].handle_left_type = 'VECTOR'
- selected4[1].handle_right_type = 'ALIGNED'
- selected4[2].handle_left_type = 'ALIGNED'
- else:
- selected4[1].handle_right_type = 'VECTOR'
- selected4[2].handle_left_type = 'VECTOR'
- selected4[2].handle_right_type = 'ALIGNED'
- selected4[1].handle_left_type = 'ALIGNED'
- if self.Fillet_Type == 'Chamfer':
- selected4[2].handle_right_type = 'VECTOR'
- selected4[1].handle_left_type = 'VECTOR'
- selected4[1].handle_right_type = 'VECTOR'
- selected4[2].handle_left_type = 'VECTOR'
- sn += 1
-
- return {'FINISHED'}
-
-def subdivide_cubic_bezier(p1, p2, p3, p4, t):
- p12 = (p2 - p1) * t + p1
- p23 = (p3 - p2) * t + p2
- p34 = (p4 - p3) * t + p3
- p123 = (p23 - p12) * t + p12
- p234 = (p34 - p23) * t + p23
- p1234 = (p234 - p123) * t + p123
- return [p12, p123, p1234, p234, p34]
-
-
-# ------------------------------------------------------------
-# BezierDivide Operator
-
-class BezierDivide(Operator):
- bl_idname = "curve.bezier_spline_divide"
- bl_label = "Bezier Spline Divide"
- bl_description = "Bezier Divide (enters edit mode) for Fillet Curves"
- bl_options = {'REGISTER', 'UNDO'}
-
- # align_matrix for the invoke
- align_matrix : Matrix()
-
- Bezier_t : FloatProperty(
- name="t (0% - 100%)",
- default=50.0,
- min=0.0, soft_min=0.0,
- max=100.0, soft_max=100.0,
- description="t (0% - 100%)"
- )
-
- @classmethod
- def poll(cls, context):
- return (context.object is not None and
- context.object.type == 'CURVE')
-
- def execute(self, context):
- # main function
- if bpy.ops.object.mode_set.poll():
- bpy.ops.object.mode_set(mode='EDIT')
-
- splines = bpy.context.object.data.splines
- s = []
- for spline in splines:
- bpy.ops.curve.spline_type_set(type='BEZIER')
-
- n = 0
- ii = []
- for p in spline.bezier_points:
- if p.select_control_point:
- ii.append(n)
- n += 1
- else:
- n += 1
- s.append(ii)
-
- sn = 0
- for spline in splines:
- ii = s[sn]
- n = len(spline.bezier_points)
- if n > 2:
- jn = 0
- for j in ii:
-
- selected_all = [p for p in spline.bezier_points]
-
- bpy.ops.curve.select_all(action='DESELECT')
-
- if (j in ii) and (j + 1 in ii):
- selected_all[j + jn].select_control_point = True
- selected_all[j + 1 + jn].select_control_point = True
- h = subdivide_cubic_bezier(
- selected_all[j + jn].co, selected_all[j + jn].handle_right,
- selected_all[j + 1 + jn].handle_left, selected_all[j + 1 + jn].co, self.Bezier_t / 100
- )
- bpy.ops.curve.subdivide(1)
- selected_all = [p for p in spline.bezier_points]
- selected_all[j + jn].handle_right_type = 'FREE'
- selected_all[j + jn].handle_right = h[0]
- selected_all[j + 1 + jn].co = h[2]
- selected_all[j + 1 + jn].handle_left_type = 'FREE'
- selected_all[j + 1 + jn].handle_left = h[1]
- selected_all[j + 1 + jn].handle_right_type = 'FREE'
- selected_all[j + 1 + jn].handle_right = h[3]
- selected_all[j + 2 + jn].handle_left_type = 'FREE'
- selected_all[j + 2 + jn].handle_left = h[4]
- jn += 1
-
- if j == n - 1 and (0 in ii) and spline.use_cyclic_u:
- selected_all[j + jn].select_control_point = True
- selected_all[0].select_control_point = True
- h = subdivide_cubic_bezier(
- selected_all[j + jn].co, selected_all[j + jn].handle_right,
- selected_all[0].handle_left, selected_all[0].co, self.Bezier_t / 100
- )
- bpy.ops.curve.subdivide(1)
- selected_all = [p for p in spline.bezier_points]
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list