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-07-15 03:19:21 +0300
committerSpivak Vladimir (cwolf3d) <cwolf3d@gmail.com>2019-07-15 03:20:21 +0300
commit70b42a69b58f6859eabc3b4bc702a67bc2b2f42d (patch)
tree1aac23a4c201e061f1a8da61b635671c3a3a7671
parent1e208b92fcbd05c8eaceaec83dd6bf0f741e8f54 (diff)
Add Curve: Extra Objects: fix visibility, move and rotate in edit mode
-rw-r--r--add_curve_extra_objects/add_curve_aceous_galore.py78
-rw-r--r--add_curve_extra_objects/add_curve_braid.py1
-rw-r--r--add_curve_extra_objects/add_curve_curly.py47
-rw-r--r--add_curve_extra_objects/add_curve_simple.py69
-rw-r--r--add_curve_extra_objects/add_curve_spirals.py65
-rw-r--r--add_curve_extra_objects/beveltaper_curve.py1
6 files changed, 191 insertions, 70 deletions
diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py
index 5b67dcad..f5cec2fa 100644
--- a/add_curve_extra_objects/add_curve_aceous_galore.py
+++ b/add_curve_extra_objects/add_curve_aceous_galore.py
@@ -767,23 +767,39 @@ def createCurve(context, vertArray, self, align_matrix):
if bpy.context.mode == 'EDIT_CURVE':
Curve = context.active_object
newSpline = Curve.data.splines.new(type=splineType) # spline
- Curve.matrix_world = align_matrix # apply matrix
- Curve.rotation_euler = self.rotation_euler
else:
# create curve
- newCurve = bpy.data.curves.new(name, type='CURVE') # curve data block
- newSpline = newCurve.splines.new(type=splineType) # spline
-
- # set curveOptions
- newCurve.dimensions = self.shape
- newCurve.use_path = True
+ dataCurve = bpy.data.curves.new(name, type='CURVE') # curve data block
+ newSpline = dataCurve.splines.new(type=splineType) # spline
# create object with newCurve
- SimpleCurve = object_utils.object_data_add(context, newCurve, operator=self) # place in active scene
- SimpleCurve.select_set(True)
- SimpleCurve.matrix_world = align_matrix # apply matrix
- SimpleCurve.rotation_euler = self.rotation_euler
-
+ Curve = object_utils.object_data_add(context, dataCurve, operator=self) # place in active scene
+ Curve.matrix_world = align_matrix # apply matrix
+ Curve.rotation_euler = self.rotation_euler
+
+ # set newSpline Options
+ newSpline.use_cyclic_u = self.use_cyclic_u
+ newSpline.use_endpoint_u = self.endp_u
+ newSpline.order_u = self.order_u
+
+ # set curve Options
+ 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'
+
+ 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
+
# create spline from vertarray
if splineType == 'BEZIER':
newSpline.bezier_points.add(int(len(vertArray) * 0.33))
@@ -791,15 +807,23 @@ def createCurve(context, vertArray, self, align_matrix):
for point in newSpline.bezier_points:
point.handle_right_type = self.handleType
point.handle_left_type = self.handleType
+ point.select_control_point = True
+ point.select_left_handle = True
+ point.select_right_handle = True
else:
newSpline.points.add(int(len(vertArray) * 0.25 - 1))
newSpline.points.foreach_set('co', vertArray)
newSpline.use_endpoint_u = True
+ for point in newSpline.points:
+ point.select = True
+
+ # move and rotate spline in edit mode
+ if bpy.context.mode == 'EDIT_CURVE':
+ bpy.ops.transform.translate(value = self.startlocation)
+ bpy.ops.transform.rotate(value = self.rotation_euler[0], orient_axis = 'X')
+ bpy.ops.transform.rotate(value = self.rotation_euler[1], orient_axis = 'Y')
+ bpy.ops.transform.rotate(value = self.rotation_euler[2], orient_axis = 'Z')
- # set curveOptions
- newSpline.use_cyclic_u = self.use_cyclic_u
- newSpline.use_endpoint_u = self.endp_u
- newSpline.order_u = self.order_u
return
@@ -1408,6 +1432,9 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
col.prop(self, "noiseBasis")
col.prop(self, "noiseSeed")
+ row = layout.row()
+ row.prop(self, "shape", expand=True)
+
# output options
col = layout.column()
col.label(text="Output Curve Type:")
@@ -1418,8 +1445,8 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
elif self.outputType == 'BEZIER':
col.row().prop(self, 'handleType', expand=True)
- #col = layout.column()
- #col.row().prop(self, "use_cyclic_u", expand=True)
+ col = layout.column()
+ col.row().prop(self, "use_cyclic_u", expand=True)
box = layout.box()
box.label(text="Location:")
@@ -1433,6 +1460,13 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
return context.scene is not None
def execute(self, context):
+ # main function
+ self.align_matrix = align_matrix(context, self.startlocation)
+ main(context, self, self.align_matrix or Matrix())
+
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
# deal with 2D - 3D curve differences
if self.ProfileType in ['Helix', 'Cycloid', 'Noise']:
self.shape = '3D'
@@ -1451,10 +1485,8 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper):
self.use_cyclic_u = False
else:
self.use_cyclic_u = True
-
- # main function
- self.align_matrix = align_matrix(context, self.startlocation)
- main(context, self, self.align_matrix or Matrix())
+
+ self.execute(context)
return {'FINISHED'}
diff --git a/add_curve_extra_objects/add_curve_braid.py b/add_curve_extra_objects/add_curve_braid.py
index fcaaf15e..874324a8 100644
--- a/add_curve_extra_objects/add_curve_braid.py
+++ b/add_curve_extra_objects/add_curve_braid.py
@@ -96,6 +96,7 @@ def poly_line(curve, points, join=True, type='NURBS'):
def poly_lines(objname, curvename, lines, bevel=None, joins=False, ctype='NURBS'):
curve = bpy.data.curves.new(name=curvename, type='CURVE')
curve.dimensions = '3D'
+ curve.fill_mode = 'FULL'
obj = bpy.data.objects.new(objname, curve)
obj.location = (0, 0, 0) # object origin
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:
diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py
index f8df04d4..bacfe57d 100644
--- a/add_curve_extra_objects/add_curve_simple.py
+++ b/add_curve_extra_objects/add_curve_simple.py
@@ -429,25 +429,30 @@ def main(context, self, align_matrix):
if bpy.context.mode == 'EDIT_CURVE':
Curve = context.active_object
newSpline = Curve.data.splines.new(type=splineType) # spline
- Curve.matrix_world = align_matrix # apply matrix
- Curve.rotation_euler = self.Simple_rotation_euler
else:
name = self.Simple_Type # Type as name
- # create curve
- newCurve = bpy.data.curves.new(name, type='CURVE') # curvedatablock
- newSpline = newCurve.splines.new(type=splineType) # spline
-
- # set curveOptions
- newCurve.dimensions = self.shape
- newCurve.use_path = True
-
- # create object with newCurve
- SimpleCurve = object_utils.object_data_add(context, newCurve, operator=self) # place in active scene
- SimpleCurve.select_set(True)
- SimpleCurve.matrix_world = align_matrix # apply matrix
- SimpleCurve.rotation_euler = self.Simple_rotation_euler
+ dataCurve = bpy.data.curves.new(name, type='CURVE') # curve data block
+ newSpline = dataCurve.splines.new(type=splineType) # spline
+ # create object with new Curve
+ Curve = object_utils.object_data_add(context, dataCurve, operator=self) # place in active scene
+ Curve.matrix_world = align_matrix # apply matrix
+ Curve.rotation_euler = self.Simple_rotation_euler
+
+ # set newSpline Options
+ newSpline.use_cyclic_u = self.use_cyclic_u
+ newSpline.use_endpoint_u = self.endp_u
+ newSpline.order_u = self.order_u
+
+ # set curve Options
+ 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'
+
sides = abs(int((self.Simple_endangle - self.Simple_startangle) / 90))
# get verts
@@ -538,28 +543,39 @@ def main(context, self, align_matrix):
verts = SimpleTrapezoid(
self.Simple_a, self.Simple_b, self.Simple_h, self.Simple_center
)
-
- # set curveOptions
- newSpline.use_cyclic_u = self.use_cyclic_u
- newSpline.use_endpoint_u = self.endp_u
- newSpline.order_u = self.order_u
# turn verts into array
vertArray = vertsToPoints(verts, splineType)
-
+
+ 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
+
# create spline from vertarray
+ all_points = []
if splineType == 'BEZIER':
newSpline.bezier_points.add(int(len(vertArray) * 0.33))
newSpline.bezier_points.foreach_set('co', vertArray)
- all_points = [p for p in newSpline.bezier_points]
for point in newSpline.bezier_points:
point.handle_right_type = self.handleType
point.handle_left_type = self.handleType
+ point.select_control_point = True
+ point.select_left_handle = True
+ point.select_right_handle = True
+ all_points.append(point)
else:
newSpline.points.add(int(len(vertArray) * 0.25 - 1))
newSpline.points.foreach_set('co', vertArray)
newSpline.use_endpoint_u = True
- all_points = [p for p in newSpline.points]
+ for point in newSpline.points:
+ all_points.append(point)
+ point.select = True
n = len(all_points)
@@ -786,6 +802,13 @@ def main(context, self, align_matrix):
all_points[int(n / 2) - 1].handle_right_type = 'VECTOR'
all_points[int(n / 2)].handle_left_type = 'VECTOR'
+ # move and rotate spline in edit mode
+ if bpy.context.mode == 'EDIT_CURVE':
+ bpy.ops.transform.translate(value = self.Simple_startlocation)
+ bpy.ops.transform.rotate(value = self.Simple_rotation_euler[0], orient_axis = 'X')
+ bpy.ops.transform.rotate(value = self.Simple_rotation_euler[1], orient_axis = 'Y')
+ bpy.ops.transform.rotate(value = self.Simple_rotation_euler[2], orient_axis = 'Z')
+
return
# ### MENU append ###
diff --git a/add_curve_extra_objects/add_curve_spirals.py b/add_curve_extra_objects/add_curve_spirals.py
index c3945e3f..3cbb8410 100644
--- a/add_curve_extra_objects/add_curve_spirals.py
+++ b/add_curve_extra_objects/add_curve_spirals.py
@@ -233,42 +233,67 @@ def draw_curve(props, context, align_matrix):
# create object
if bpy.context.mode == 'EDIT_CURVE':
Curve = context.active_object
- spline = Curve.data.splines.new(type=splineType) # spline
+ newSpline = Curve.data.splines.new(type=splineType) # spline
else:
# create curve
- newCurve = bpy.data.curves.new(name='Spiral', type='CURVE') # curvedatablock
- spline = newCurve.splines.new(type=splineType) # spline
-
- # set curveOptions
- newCurve.dimensions = props.shape
- newCurve.use_path = True
+ dataCurve = bpy.data.curves.new(name='Spiral', type='CURVE') # curvedatablock
+ newSpline = dataCurve.splines.new(type=splineType) # spline
# create object with newCurve
- Curve = object_data_add(context, newCurve) # place in active scene
+ Curve = object_data_add(context, dataCurve) # place in active scene
+ Curve.matrix_world = align_matrix # apply matrix
+ Curve.rotation_euler = props.rotation_euler
Curve.select_set(True)
- Curve.matrix_world = align_matrix # apply matrix
- Curve.rotation_euler = props.rotation_euler
+ # set curveOptions
+ Curve.data.dimensions = props.shape
+ Curve.data.use_path = True
+ if props.shape == '3D':
+ Curve.data.fill_mode = 'FULL'
+ else:
+ Curve.data.fill_mode = 'BOTH'
# set curveOptions
- spline.use_cyclic_u = props.use_cyclic_u
- spline.use_endpoint_u = props.endp_u
- spline.order_u = props.order_u
+ newSpline.use_cyclic_u = props.use_cyclic_u
+ newSpline.use_endpoint_u = props.endp_u
+ newSpline.order_u = props.order_u
# turn verts into array
vertArray = vertsToPoints(verts, splineType)
- # create spline from vertarray
+ 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
+
+ # create newSpline from vertarray
if splineType == 'BEZIER':
- spline.bezier_points.add(int(len(vertArray) * 0.33))
- spline.bezier_points.foreach_set('co', vertArray)
- for point in spline.bezier_points:
+ newSpline.bezier_points.add(int(len(vertArray) * 0.33))
+ newSpline.bezier_points.foreach_set('co', vertArray)
+ for point in newSpline.bezier_points:
point.handle_right_type = props.handleType
point.handle_left_type = props.handleType
+ point.select_control_point = True
+ point.select_left_handle = True
+ point.select_right_handle = True
else:
- spline.points.add(int(len(vertArray) * 0.25 - 1))
- spline.points.foreach_set('co', vertArray)
- spline.use_endpoint_u = False
+ newSpline.points.add(int(len(vertArray) * 0.25 - 1))
+ newSpline.points.foreach_set('co', vertArray)
+ newSpline.use_endpoint_u = False
+ for point in newSpline.points:
+ point.select = True
+
+ # move and rotate spline in edit mode
+ if bpy.context.mode == 'EDIT_CURVE':
+ bpy.ops.transform.translate(value = props.startlocation)
+ bpy.ops.transform.rotate(value = props.rotation_euler[0], orient_axis = 'X')
+ bpy.ops.transform.rotate(value = props.rotation_euler[1], orient_axis = 'Y')
+ bpy.ops.transform.rotate(value = props.rotation_euler[2], orient_axis = 'Z')
class CURVE_OT_spirals(Operator):
bl_idname = "curve.spirals"
diff --git a/add_curve_extra_objects/beveltaper_curve.py b/add_curve_extra_objects/beveltaper_curve.py
index 608b5bf5..948afa5f 100644
--- a/add_curve_extra_objects/beveltaper_curve.py
+++ b/add_curve_extra_objects/beveltaper_curve.py
@@ -213,6 +213,7 @@ def make_curve(self, context, verts, lh, rh):
name=target.name + '_Bevel', type='CURVE'
)
curve_data.dimensions = '3D'
+ curve_data.fill_mode = 'FULL'
for p in range(len(verts)):
c = 0