From ef40e0daf220d24e6e91f3d6b7f4272ffb4d7546 Mon Sep 17 00:00:00 2001 From: "Spivak Vladimir (cwolf3d)" Date: Fri, 11 Oct 2019 03:38:17 +0300 Subject: Addon: Add Curve: Extra Objects: Added switch to display in edit mode by create object --- add_curve_extra_objects/add_curve_aceous_galore.py | 15 ++++++++++++ add_curve_extra_objects/add_curve_braid.py | 13 +++++++++++ add_curve_extra_objects/add_curve_curly.py | 27 +++++++++++++++++----- add_curve_extra_objects/add_curve_simple.py | 19 +++++++++++++++ add_curve_extra_objects/add_curve_spirals.py | 13 +++++++++++ add_curve_extra_objects/add_curve_torus_knots.py | 13 +++++++++++ add_curve_extra_objects/beveltaper_curve.py | 26 +++++++++++++++++++++ 7 files changed, 120 insertions(+), 6 deletions(-) diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py index 95d38902..c27d26dd 100644 --- a/add_curve_extra_objects/add_curve_aceous_galore.py +++ b/add_curve_extra_objects/add_curve_aceous_galore.py @@ -1300,6 +1300,13 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): min=0, description="Random Seed" ) + + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) + # Line properties startlocation : FloatVectorProperty( name="", @@ -1448,6 +1455,9 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): col = layout.column() col.row().prop(self, "use_cyclic_u", expand=True) + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) + box = layout.box() box.label(text="Location:") box.prop(self, "startlocation") @@ -1473,6 +1483,11 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_braid.py b/add_curve_extra_objects/add_curve_braid.py index 16e072d4..ae250682 100644 --- a/add_curve_extra_objects/add_curve_braid.py +++ b/add_curve_extra_objects/add_curve_braid.py @@ -204,6 +204,11 @@ class Braid(Operator): description="Switch between round and sharp corners", default=False ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) def draw(self, context): layout = self.layout @@ -227,6 +232,9 @@ class Braid(Operator): col.label(text="Geometry Options:") col.prop(self, "strandsize") col.prop(self, "resolution") + + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) def execute(self, context): # turn off 'Enter Edit Mode' @@ -257,6 +265,11 @@ class Braid(Operator): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') + return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_curly.py b/add_curve_extra_objects/add_curve_curly.py index b5243766..1ac76341 100644 --- a/add_curve_extra_objects/add_curve_curly.py +++ b/add_curve_extra_objects/add_curve_curly.py @@ -17,6 +17,7 @@ bl_info = { import bpy from bpy.types import Operator from bpy.props import ( + BoolProperty, FloatProperty, EnumProperty, IntProperty, @@ -486,17 +487,17 @@ class add_curlycurve(Operator, AddObjectHelper): ('3D', "3D", "3D") ] ) + + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) def draw(self, context): layout = self.layout col = layout.column(align=True) - # AddObjectHelper props - col.prop(self, "align") - col.prop(self, "location") - col.prop(self, "rotation") - - col = layout.column() col.label(text = "Curve:") col.prop(self, "types") @@ -507,6 +508,15 @@ class add_curlycurve(Operator, AddObjectHelper): row = layout.row() row.prop(self, "shape", expand=True) + + col = layout.column(align=True) + col.row().prop(self, "edit_mode", expand=True) + + col = layout.column(align=True) + # AddObjectHelper props + col.prop(self, "align") + col.prop(self, "location") + col.prop(self, "rotation") def execute(self, context): # turn off 'Enter Edit Mode' @@ -540,6 +550,11 @@ class add_curlycurve(Operator, AddObjectHelper): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') + return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py index 129f66bf..e0dc2807 100644 --- a/add_curve_extra_objects/add_curve_simple.py +++ b/add_curve_extra_objects/add_curve_simple.py @@ -675,6 +675,8 @@ def main(context, self, align_matrix, use_enter_edit_mode): p1.handle_right = v1 p2.handle_left = v2 i += 1 + all_points[0].handle_left_type = 'VECTOR' + all_points[-1].handle_right_type = 'VECTOR' if self.Simple_Type == 'Sector': i = 0 @@ -713,6 +715,10 @@ def main(context, self, align_matrix, use_enter_edit_mode): p1.handle_right = v1 p2.handle_left = v2 i += 1 + all_points[0].handle_left_type = 'VECTOR' + all_points[0].handle_right_type = 'VECTOR' + all_points[1].handle_left_type = 'VECTOR' + all_points[-1].handle_right_type = 'VECTOR' if self.Simple_Type == 'Segment': i = 0 @@ -1066,6 +1072,11 @@ class Simple(Operator, object_utils.AddObjectHelper): ('VECTOR', "Vector", "Vector type Bezier handles"), ('AUTO', "Auto", "Automatic type Bezier handles")] ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) def draw(self, context): layout = self.layout @@ -1255,6 +1266,9 @@ class Simple(Operator, object_utils.AddObjectHelper): col = layout.column() col.row().prop(self, "use_cyclic_u", expand=True) + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) + box = layout.box() box.label(text="Location:") box.prop(self, "Simple_startlocation") @@ -1291,6 +1305,11 @@ class Simple(Operator, object_utils.AddObjectHelper): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_spirals.py b/add_curve_extra_objects/add_curve_spirals.py index c669642f..e916fbe5 100644 --- a/add_curve_extra_objects/add_curve_spirals.py +++ b/add_curve_extra_objects/add_curve_spirals.py @@ -430,6 +430,11 @@ class CURVE_OT_spirals(Operator): ('VECTOR', "Vector", "Vector type Bezier handles"), ('AUTO', "Auto", "Automatic type Bezier handles")] ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) startlocation : FloatVectorProperty( name="", description="Start location", @@ -521,6 +526,9 @@ class CURVE_OT_spirals(Operator): col = layout.column() col.row().prop(self, "use_cyclic_u", expand=True) + + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) box = layout.box() box.label(text="Location:") @@ -547,6 +555,11 @@ class CURVE_OT_spirals(Operator): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') #self.report({'INFO'}, #"Drawing Spiral Finished: %.4f sec" % (time.time() - time_start)) diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py index 29c61011..95207493 100644 --- a/add_curve_extra_objects/add_curve_torus_knots.py +++ b/add_curve_extra_objects/add_curve_torus_knots.py @@ -562,6 +562,11 @@ class torus_knot_plus(Operator, AddObjectHelper): default=False, description="Auto adjust curve resolution based on TK length", ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) def draw(self, context): layout = self.layout @@ -664,6 +669,9 @@ class torus_knot_plus(Operator, AddObjectHelper): box.prop(self, "colorSet") box.prop(self, "random_colors") box.prop(self, "saturation") + + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) # TRANSFORM options col = layout.column() @@ -720,6 +728,11 @@ class torus_knot_plus(Operator, AddObjectHelper): # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') + return {'FINISHED'} def invoke(self, context, event): diff --git a/add_curve_extra_objects/beveltaper_curve.py b/add_curve_extra_objects/beveltaper_curve.py index 948afa5f..d3cc4a93 100644 --- a/add_curve_extra_objects/beveltaper_curve.py +++ b/add_curve_extra_objects/beveltaper_curve.py @@ -275,6 +275,11 @@ class add_tapercurve(Operator): default=1, description="Difference between ends and center while linked" ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) @classmethod def poll(cls, context): @@ -308,6 +313,9 @@ class add_tapercurve(Operator): col_sub.active = self.link2 row.prop(self, "link2", toggle=True, text="", icon="LINKED") col_sub.prop(self, "diff") + + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) def execute(self, context): if self.link1: @@ -317,6 +325,11 @@ class add_tapercurve(Operator): self.scale_ends2 = self.scale_ends1 = self.scale_mid - self.diff add_taper(self, context) + + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} @@ -349,6 +362,11 @@ class add_bevelcurve(Operator, AddObjectHelper): description="Link the Scale on X/Y axis", default=True ) + edit_mode : BoolProperty( + name="Show in edit mode", + default=True, + description="Show in edit mode" + ) @classmethod def poll(cls, context): @@ -376,6 +394,9 @@ class add_bevelcurve(Operator, AddObjectHelper): col.prop(self, "scale_y") row.prop(self, "link", toggle=True, text="", icon="LINKED") + col = layout.column() + col.row().prop(self, "edit_mode", expand=True) + def execute(self, context): if self.link: self.scale_y = self.scale_x @@ -389,6 +410,11 @@ class add_bevelcurve(Operator, AddObjectHelper): add_type4(self, context) if self.types == 5: add_type5(self, context) + + if self.edit_mode: + bpy.ops.object.mode_set(mode = 'EDIT') + else: + bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} -- cgit v1.2.3