1

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!

Cubes being parented to a Curve with Python

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()

  • 1
    it works if your circle is a mesh but not if it is a curve. why don't you convert it to mesh? or maybe report it as a bug – Harry McKenzie Aug 27 '22 at 02:17

1 Answers1

0

The curve data's use_path needs to be disabled for the parenting to work with the curve's origin.

cube = bpy.data.objects["Cube"]
curve = bpy.data.objects["Circle"]
curve.data.use_path = False
cube.parent = curve
cube.matrix_parent_inverse = curve.matrix_world.inverted()
  • i see your ticket is resolved https://developer.blender.org/T100661 but how did you find out? – Harry McKenzie Aug 27 '22 at 04:06
  • 1
    @HarryMcKenzie I started ticking checkboxes in the Curve's properties and saw the relationship lines change with Path Animation. Thank you for the concern and the replies - very much appreciated! – Dr. Pontchartrain Aug 27 '22 at 23:23