diff options
author | Spivak Vladimir (cwolf3d) <cwolf3d@gmail.com> | 2019-04-28 22:13:25 +0300 |
---|---|---|
committer | Spivak Vladimir (cwolf3d) <cwolf3d@gmail.com> | 2019-04-28 22:13:25 +0300 |
commit | b3716b48604e18c2cb7cc96dd16d26d3b0870769 (patch) | |
tree | 7898c005ecbeb0305d57f4628d4fcd870e407202 /add_curve_extra_objects/add_curve_curly.py | |
parent | 77f532164736c68e9e87b5c89cbfef7d292ae7a7 (diff) |
implementation of adding curly (add_curve_curly) 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 | 75 |
1 files changed, 51 insertions, 24 deletions
diff --git a/add_curve_extra_objects/add_curve_curly.py b/add_curve_extra_objects/add_curve_curly.py index 8cd7d8b9..3a8153b5 100644 --- a/add_curve_extra_objects/add_curve_curly.py +++ b/add_curve_extra_objects/add_curve_curly.py @@ -179,11 +179,13 @@ def add_type2(self, context): scale_x = self.scale_x scale_y = self.scale_y verts = [ - [-0.719632 * scale_x, -0.08781 * scale_y, - 0.0, -0.605138 * scale_x, -0.31612 * scale_y, - 0.0, -0.935392 * scale_x, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.935392 * scale_x, 0.0, 0.0, 0.605138 * scale_x, - -0.316119 * scale_y, 0.0, 0.719632 * scale_x, -0.08781 * scale_y, 0.0] + [-0.719632 * scale_x, -0.08781 * scale_y, 0.0, + -0.605138 * scale_x, -0.31612 * scale_y, 0.0, + -0.935392 * scale_x, 0.0, 0.0, + 0.0, 0.0, 0.0, + 0.935392 * scale_x, 0.0, 0.0, + 0.605138 * scale_x, -0.316119 * scale_y, 0.0, + 0.719632 * scale_x, -0.08781 * scale_y, 0.0] ] lhandles = [ [(-0.82125 * scale_x, -0.142999 * scale_y, 0.0), @@ -380,26 +382,51 @@ def add_type1(self, context): def make_curve(self, context, verts, lh, rh): types = self.types - curve_data = bpy.data.curves.new(name='CurlyCurve', type='CURVE') - curve_data.dimensions = '3D' - - for p in range(len(verts)): - c = 0 - spline = curve_data.splines.new(type='BEZIER') - spline.bezier_points.add(len(verts[p]) / 3 - 1) - spline.bezier_points.foreach_set('co', verts[p]) - - for bp in spline.bezier_points: - bp.handle_left_type = 'ALIGNED' - bp.handle_right_type = 'ALIGNED' - bp.handle_left.xyz = lh[p][c] - bp.handle_right.xyz = rh[p][c] - c += 1 - # something weird with this one - if types == 1 or types == 2 or types == 3: - spline.bezier_points[3].handle_left.xyz = lh[p][3] - object_data_add(context, curve_data, operator=self) + # create object + if bpy.context.mode == 'EDIT_CURVE': + Curve = context.active_object + for p in range(len(verts)): + c = 0 + newSpline = Curve.data.splines.new(type='BEZIER') # newSpline + newSpline.bezier_points.add(len(verts[p]) / 3 - 1) + newSpline.bezier_points.foreach_set('co', verts[p]) + + for bp in newSpline.bezier_points: + bp.handle_left_type = 'ALIGNED' + bp.handle_right_type = 'ALIGNED' + bp.handle_left.xyz = lh[p][c] + bp.handle_right.xyz = rh[p][c] + 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] + else: + # create curve + newCurve = 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.bezier_points.add(len(verts[p]) / 3 - 1) + newSpline.bezier_points.foreach_set('co', verts[p]) + + for bp in newSpline.bezier_points: + bp.handle_left_type = 'ALIGNED' + bp.handle_right_type = 'ALIGNED' + bp.handle_left.xyz = lh[p][c] + bp.handle_right.xyz = rh[p][c] + 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.select_set(True) + + # set curveOptions + Curve.data.dimensions = '3D' + Curve.data.use_path = True class add_curlycurve(Operator, AddObjectHelper): bl_idname = "curve.curlycurve" |