1
$\begingroup$

I have parent and child objects. I want the child to move and rotate with the parent, but I would like to be able to scale the parent without affecting the child in my Python script. I know that I can set the parent to transform independently with this: bpy.context.scene.tool_settings.use_transform_skip_children = True or in the Options menu in the upper right hand corner of the 3d view window.

In my Python code, I would like to be able to detect that a translation in the parent object is occurring, set the parent to transform independently, and then reset that the child transform with the parent. Is that possible? I am not sure if a modal operator would work, and I do not know what to call the event that would trigger it.

$\endgroup$
4
  • 3
    $\begingroup$ If your overall goal is to have the child translate and rotate with its parent but scale independently, then one option is to use a Child Of constraint instead of parenting. Clear any parent the "child" object may have with Alt+P, then add the Child Of constraint. Once you assign the "parent", you can then choose which components of its transform are inherited (you can disable all three scale axes). $\endgroup$ Feb 24 at 2:13
  • $\begingroup$ This is an answer TTJ $\endgroup$ Feb 24 at 2:48
  • $\begingroup$ @TheTrueJard please write this as an answer and not as a comment, so that it can be upvoted and accepted. $\endgroup$
    – susu
    Feb 24 at 21:46
  • $\begingroup$ I originally added it as a comment cause it seemed the OP might want a python solution, but after re-reading it I see otherwise. I've added the answer now. $\endgroup$ Feb 25 at 8:57
2
$\begingroup$

If your overall goal is to have the child translate and rotate with its parent but scale independently, then one option is to use a Child Of constraint instead of parenting. This solution does not require any Python scripting.

  1. Clear any parent the "child" object may already have with Alt+P.
  2. Add the Child Of constraint. Once you assign the "parent" object, you can choose which components of its transform are inherited. In your specific case, you'll want to disable all three scale axes.
$\endgroup$
1
  • 1
    $\begingroup$ I had not used constraints before, so this answered my question. I do need to use Python, and this is what I came up with: constraint=objchild.constraints.new("CHILD_OF"), constraint.target=obparent, constraint.inverse_matrix = objchild.matrix_world.inverted(), constraint.use_scale_x=False, etc. I think it is mostly working. $\endgroup$
    – SJK
    Feb 26 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.