Skip to content

Commit

Permalink
"Apply field to curve": explicit "join" flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Jun 25, 2021
1 parent b3acf49 commit cc56063
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions nodes/curve/apply_field_to_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ class SvApplyFieldToCurveNode(bpy.types.Node, SverchCustomTreeNode):
default = False,
update=updateNode)

join : BoolProperty(
name = "Join",
description = "Output single flat list of curves",
default = True,
update=updateNode)

def sv_init(self, context):
self.inputs.new('SvVectorFieldSocket', "Field")
self.inputs.new('SvCurveSocket', "Curve")
self.inputs.new('SvStringsSocket', "Coefficient").prop_name = 'coefficient'
self.outputs.new('SvCurveSocket', "Curve")

def draw_buttons(self, context, layout):
layout.prop(self, "use_control_points", toggle=True)
layout.prop(self, "use_control_points", toggle=False)
layout.prop(self, "join", toggle=False)

def process(self):
if not any(socket.is_linked for socket in self.outputs):
Expand All @@ -55,6 +62,7 @@ def process(self):

curve_out = []
for curve_i, field_i, coeff_i in zip_long_repeat(curve_s, field_s, coeff_s):
new_curves = []
for curve, field, coeff in zip_long_repeat(curve_i, field_i, coeff_i):
if self.use_control_points:
nurbs = SvNurbsCurve.to_nurbs(curve)
Expand Down Expand Up @@ -83,7 +91,12 @@ def process(self):
new_curve.u_bounds = nurbs.u_bounds
else:
new_curve = SvDeformedByFieldCurve(curve, field, coeff)
curve_out.append(new_curve)
new_curves.append(new_curve)

if self.join:
curve_out.extend(new_curves)
else:
curve_out.append(new_curves)

self.outputs['Curve'].sv_set(curve_out)

Expand Down

0 comments on commit cc56063

Please sign in to comment.