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.
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?
This is image of the direction I would like the Tilt -