From 5a9fd6f8b88402483748f88f461f984a1614e22d Mon Sep 17 00:00:00 2001 From: "Ilya V. Portnov" Date: Thu, 14 Nov 2024 22:01:29 +0500 Subject: [PATCH 1/2] "Bezier in" node: output curve tilt & radius parameters. --- nodes/exchange/bezier_in.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/nodes/exchange/bezier_in.py b/nodes/exchange/bezier_in.py index 6f4db78972..111905951e 100644 --- a/nodes/exchange/bezier_in.py +++ b/nodes/exchange/bezier_in.py @@ -70,6 +70,8 @@ def sv_init(self, context): self.outputs.new('SvCurveSocket', 'Curves') self.outputs.new('SvVerticesSocket', 'ControlPoints') self.outputs.new('SvMatrixSocket', 'Matrices') + self.outputs.new('SvStringsSocket', 'Tilt') + self.outputs.new('SvStringsSocket', 'Radius') def get_objects_from_scene(self, ops): """ @@ -137,7 +139,6 @@ def get_curve(self, spline, matrix): if spline.use_cyclic_u: pairs = list(pairs) + [(spline.bezier_points[-1], spline.bezier_points[0])] points = [] - is_first = True for p1, p2 in pairs: c0 = p1.co c1 = p1.handle_right @@ -150,10 +151,18 @@ def get_curve(self, spline, matrix): points.append([c0, c1, c2, c3]) segment = SvCubicBezierCurve(c0, c1, c2, c3) segments.append(segment) + + tilt_values = [] + radius_values = [] if self.concat_segments: - return points, concatenate_curves(segments) + tilt_values = [p.tilt for p in spline.bezier_points] + radius_values = [p.radius for p in spline.bezier_points] + return points, tilt_values, radius_values, concatenate_curves(segments) else: - return points, segments + for p1, p2 in pairs: + tilt_values.append([p1.tilt, p2.tilt]) + radius_values.append([p1.radius, p2.radius]) + return points, tilt_values, radius_values, segments def process(self): @@ -163,6 +172,8 @@ def process(self): curves_out = [] matrices_out = [] controls_out = [] + tilt_out = [] + radius_out = [] for item in self.object_names: object_name = item.name obj = bpy.data.objects.get(object_name) @@ -177,14 +188,20 @@ def process(self): if spline.type != 'BEZIER': self.warning("%s: not supported spline type: %s", spline, spline.type) continue - controls, curve = self.get_curve(spline, matrix) + controls, tilt_values, radius_values, curve = self.get_curve(spline, matrix) curves_out.append(curve) controls_out.append(controls) matrices_out.append(matrix) + tilt_out.append(tilt_values) + radius_out.append(radius_values) self.outputs['Curves'].sv_set(curves_out) self.outputs['ControlPoints'].sv_set(controls_out) self.outputs['Matrices'].sv_set(matrices_out) + if 'Tilt' in self.outputs: + self.outputs['Tilt'].sv_set(tilt_out) + if 'Radius' in self.outputs: + self.outputs['Radius'].sv_set(radius_out) def register(): From 8b5b4dcb959f31d45a2de6ccbbd3095ad3e9b389 Mon Sep 17 00:00:00 2001 From: "Ilya V. Portnov" Date: Thu, 14 Nov 2024 22:05:01 +0500 Subject: [PATCH 2/2] Update documentation --- docs/nodes/exchange/bezier_in.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/nodes/exchange/bezier_in.rst b/docs/nodes/exchange/bezier_in.rst index fb627b0824..9c7b44d4db 100644 --- a/docs/nodes/exchange/bezier_in.rst +++ b/docs/nodes/exchange/bezier_in.rst @@ -48,4 +48,9 @@ This node has the following outputs: * **Curves**. Generated Curve objects. * **ControlPoints**. Control points of Bezier curves. This output contains a list of 4 points for each segments of each Bezier curve. * **Matrices**. Transformation matrices of selected objects. +* **Tilt**. Tilt values from Blender's curve object. This output contains one + value for each Bezier's control point in Blender terms (or, in more strict + terms, one value for each point where one Bezier segment ends and new one + starts). +* **Radius**. Radius values from Blender's curve object. Similar to **Tilt** output.