0

I am interested in a script that could reassign the Z values of the control point handles in this curve to 0. Are these variables accessible to change via Python? Seems simple enough but my coding skillset is limited. Any help is appreciated.

https://i.stack.imgur.com/TBbPI.jpg

Following the link by batFINGER I attempted the following. My own simplistic coding knowledge is a limit here, unfortunately. Running the following does not produce errors but does nothing as well. If I move my last "for" statement outside of the "def", I get an "AssertionError" with line 17 and 45. (Note, I said 0 in original question but probably want "1" and "-1"? I just want the control point handles to align with the Z axis)

import bpy
import mathutils.geometry

The parameters can be found by taking the coordinate and

right handle of a point, and the coordinate and

left handle of the next point in the Bezier points array.

For cyclic curves the last point and the first point in the array

form an extra segment.

selected = bpy.context.selected_objects

def printInterpolatedCurveSegmentPoints(existingCurveObj):

spline = existingCurveObj.data.splines[0]
numSegments = len(spline.bezier_points)
assert(numSegments >= 2)

r = spline.resolution_u
if spline.use_cyclic_u:
    numSegments += 1

points = []
for i in range(numSegments):
    nextIdx = (i + 1) % numSegments

    knot1 = spline.bezier_points[i].co
    handle1 = spline.bezier_points[i].handle_right
    handle1.pointVec[2] = 1
    handle2 = spline.bezier_points[nextIdx].handle_left
    handle2.pointVec[2] = 1
    knot2 = spline.bezier_points[nextIdx].co

    _points = mathutils.geometry.interpolate_bezier(knot1, handle1, handle2, knot2, r)
    points.extend(_points)

assert('3D' == existingCurveObj.data.dimensions)
for pointVec in points:
    print("Point X:", pointVec[0])
    print("Point Y:", pointVec[1])
    print("Point Z:", pointVec[2])
    print()

for obj in selected:
    printInterpolatedCurveSegmentPoints(obj)

Image of the problem. I have a mesh that I'm getting a set of outer vertices from. I have an Array and Curve modifier which allows my object to follow the curve. I want this wall to be vertical - not follow the Tilt of the inner arm of the Control Points - not sure the correct term. Maybe if I reassign the Face Normals before creating the Curve from the mesh, the points would align with the Z axis?

https://i.stack.imgur.com/kRnk4.jpg

This is image of the direction I would like the Tilt -

https://i.stack.imgur.com/phw8J.jpg

  • https://blender.stackexchange.com/questions/48924/how-to-access-coordinates-of-bezier-curve-control-point-handles – batFINGER May 02 '21 at 13:38
  • Appreciate the link. I had experimented with that but mostly due to my own limited knowledge could not fully apply it. When I run my edits to that, nothing happens. I added a few lines to assign the pointVec on the 2 handles. I even tried without my edits. I'm sure a bit of it has to do with how I am trying to alter my selected object. – DP Roberts May 02 '21 at 14:16
  • It also seems that the above script will be handling the Bezier points and not the Control Points of the curve. Maybe "control vertices" is the correct term for the Tilt arms. I'm just trying to auto place an object with an array and curve and unfortunately, the object follows the Curve Tilt. – DP Roberts May 02 '21 at 15:01
  • https://blender.stackexchange.com/questions/191933/how-can-i-get-position-and-type-of-handle-in-bezier-curve https://blender.stackexchange.com/questions/117062/fcurve-handles-to-3d-b%c3%a9zier-spline-control-points – batFINGER May 02 '21 at 15:09
  • batFINGER - I'm sure I'm just not using the correct verbage here. I am not trying to alter the Bezier handles. I need an object to follow a curve but always be placed in line with the Z axis. This curve originally comes for the outer vertices of a mesh. So, maybe before I convert it to a curve, I can have the face normals be vertical and the Control Points (Tilt axis) will be in line with the Z? I am posting an image above to show the issue. – DP Roberts May 02 '21 at 15:17
  • 1
    Could you please edit question to make images inline again. Think you have an XY Problem AFAIK the handles represent the tangent (or derivative) of the incoming spline segments to the point. Can't really set them orthogonal to the direction of curve. Possibly you are after the tilt. Select a control point in edit mode and N to see the setting. – batFINGER May 02 '21 at 15:44
  • Yes - well, may have been easier to show issue and say "How can this be solved?" as my original question was truly not truly what I wanted answered. (haha) My solution is going to be creating a second set of vertices and extruding them -Z and then using that as the mesh. After mesh to curve - it does what I want. I struggle with this BB interface to add images correctly to an Edit. Oh well, appreciate you helping me get to the answer I needed - even if it wasn't where I started. – DP Roberts May 02 '21 at 16:01

0 Answers0