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>2019-04-28 22:13:25 +0300
committerSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2019-04-28 22:13:25 +0300
commitb3716b48604e18c2cb7cc96dd16d26d3b0870769 (patch)
tree7898c005ecbeb0305d57f4628d4fcd870e407202 /add_curve_extra_objects
parent77f532164736c68e9e87b5c89cbfef7d292ae7a7 (diff)
implementation of adding curly (add_curve_curly) in edit mode
Diffstat (limited to 'add_curve_extra_objects')
-rw-r--r--add_curve_extra_objects/__init__.py5
-rw-r--r--add_curve_extra_objects/add_curve_curly.py75
2 files changed, 53 insertions, 27 deletions
diff --git a/add_curve_extra_objects/__init__.py b/add_curve_extra_objects/__init__.py
index 1653ad86..321e1663 100644
--- a/add_curve_extra_objects/__init__.py
+++ b/add_curve_extra_objects/__init__.py
@@ -248,14 +248,13 @@ def menu_func(self, context):
layout.operator_menu_enum("curve.curveaceous_galore", "ProfileType", icon='CURVE_DATA')
layout.operator_menu_enum("curve.spirals", "spiral_type", icon='CURVE_DATA')
+ layout.separator()
+ layout.operator("curve.curlycurve", text="Curly Curve", icon='CURVE_DATA')
if context.mode != 'OBJECT':
# fix in D2142 will allow to work in EDIT_CURVE
return None
layout.separator()
-
layout.menu(INFO_MT_curve_knots_add.bl_idname, text="Knots", icon='CURVE_DATA')
- layout.separator()
- layout.operator("curve.curlycurve", text="Curly Curve", icon='CURVE_DATA')
#layout.menu(VIEW3D_MT_bevel_taper_curve_menu, text="Bevel/Taper", icon='CURVE_DATA')
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"