I'm trying to set a Curve as a parent to objects using Python. My Curve's position is 0,0,0 at the World Origin. When I run the script below, the cubes get parented to the Curve and jump to a different location, yet their location values stay the same. Can someone please show me how to parent these objects to the Curve while keeping their world transforms?
Note: I noticed a more correct location when setting the Curve's dimensions to 3D.
Thank you!
import bpy
from mathutils import Vector
cube1 = bpy.data.objects["Cube"]
cube2 = bpy.data.objects["Cube.001"]
curve = bpy.data.objects["Circle.001"]
objects = [cube1,cube2]
for o in objects:
o.parent = curve
o.matrix_parent_inverse = curve.matrix_world.inverted()