diff options
author | Spivak Vladimir (cwolf3d) <cwolf3d@gmail.com> | 2019-07-15 03:19:21 +0300 |
---|---|---|
committer | Spivak Vladimir (cwolf3d) <cwolf3d@gmail.com> | 2019-07-15 03:20:21 +0300 |
commit | 70b42a69b58f6859eabc3b4bc702a67bc2b2f42d (patch) | |
tree | 1aac23a4c201e061f1a8da61b635671c3a3a7671 /add_curve_extra_objects/add_curve_curly.py | |
parent | 1e208b92fcbd05c8eaceaec83dd6bf0f741e8f54 (diff) |
Add Curve: Extra Objects: fix visibility, move and rotate in edit mode
Diffstat (limited to 'add_curve_extra_objects/add_curve_curly.py')
-rw-r--r-- | add_curve_extra_objects/add_curve_curly.py | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/add_curve_extra_objects/add_curve_curly.py b/add_curve_extra_objects/add_curve_curly.py index 813509c1..e904a070 100644 --- a/add_curve_extra_objects/add_curve_curly.py +++ b/add_curve_extra_objects/add_curve_curly.py @@ -18,6 +18,7 @@ import bpy from bpy.types import Operator from bpy.props import ( FloatProperty, + EnumProperty, IntProperty, ) from bpy_extras.object_utils import ( @@ -386,6 +387,17 @@ def make_curve(self, context, verts, lh, rh): # create object if bpy.context.mode == 'EDIT_CURVE': Curve = context.active_object + + for spline in Curve.data.splines: + if spline.type == 'BEZIER': + for point in spline.bezier_points: + point.select_control_point = False + point.select_left_handle = False + point.select_right_handle = False + else: + for point in spline.points: + point.select = False + for p in range(len(verts)): c = 0 newSpline = Curve.data.splines.new(type='BEZIER') # newSpline @@ -397,16 +409,24 @@ def make_curve(self, context, verts, lh, rh): bp.handle_right_type = 'ALIGNED' bp.handle_left.xyz = lh[p][c] bp.handle_right.xyz = rh[p][c] + bp.select_control_point = True + bp.select_left_handle = True + bp.select_right_handle = True c += 1 # something weird with this one if types == 1 or types == 2 or types == 3: newSpline.bezier_points[3].handle_left.xyz = lh[p][3] + + bpy.ops.transform.translate(value = self.location) + bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X') + bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y') + bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z') else: # create curve - newCurve = bpy.data.curves.new(name='CurlyCurve', type='CURVE') # curvedatablock + dataCurve = bpy.data.curves.new(name='CurlyCurve', type='CURVE') # curvedatablock for p in range(len(verts)): c = 0 - newSpline = newCurve.splines.new(type='BEZIER') # newSpline + newSpline = dataCurve.splines.new(type='BEZIER') # newSpline newSpline.bezier_points.add(len(verts[p]) / 3 - 1) newSpline.bezier_points.foreach_set('co', verts[p]) @@ -415,18 +435,25 @@ def make_curve(self, context, verts, lh, rh): bp.handle_right_type = 'ALIGNED' bp.handle_left.xyz = lh[p][c] bp.handle_right.xyz = rh[p][c] + bp.select_control_point = True + bp.select_left_handle = True + bp.select_right_handle = True c += 1 # something weird with this one if types == 1 or types == 2 or types == 3: newSpline.bezier_points[3].handle_left.xyz = lh[p][3] # create object with newCurve - Curve = object_data_add(context, newCurve, operator=self) # place in active scene + Curve = object_data_add(context, dataCurve, operator=self) # place in active scene Curve.select_set(True) # set curveOptions - Curve.data.dimensions = '3D' + Curve.data.dimensions = self.shape Curve.data.use_path = True + if self.shape == '3D': + Curve.data.fill_mode = 'FULL' + else: + Curve.data.fill_mode = 'BOTH' class add_curlycurve(Operator, AddObjectHelper): bl_idname = "curve.curlycurve" @@ -450,6 +477,15 @@ class add_curlycurve(Operator, AddObjectHelper): description="Scale on Y axis", default=1.0 ) + # Curve Options + shape : EnumProperty( + name="2D / 3D", + description="2D or 3D Curve", + items=[ + ('2D', "2D", "2D"), + ('3D', "3D", "3D") + ] + ) def draw(self, context): layout = self.layout @@ -468,6 +504,9 @@ class add_curlycurve(Operator, AddObjectHelper): col.label(text = "Resize:") col.prop(self, "scale_x") col.prop(self, "scale_y") + + row = layout.row() + row.prop(self, "shape", expand=True) def execute(self, context): if self.types == 1: |