0
$\begingroup$

I want to create an empty for every object selected (with its coordinates) and parent each object to the empty. I found this solution

How to create an empty per object in selection?

In that link they share this code where it says "If you want the empties to be the parents :"

import bpy

for obj in bpy.context.selected_objects:  # Loop over all selected objects
    empty = bpy.data.objects.new(obj.name + "_Empty", None)  # Create new empty object
    obj.users_collection[0].objects.link(empty)  # Link empty to the current object's collection
    empty.empty_display_type = 'PLAIN_AXES'
    empty.location = obj.location
    obj.parent = empty
    obj.location = (0, 0, 0)

But the nulls appear in the world's origin not in the objects' origin.

enter image description here

Any idea to get it?

Thanks

$\endgroup$
11
  • 1
    $\begingroup$ What is the meaning of this sentence: "But the nulls appear in the world origin not in the object origin." $\endgroup$
    – lemon
    Nov 21 at 10:58
  • 1
    $\begingroup$ If you want to do this with python, please use the python tag on your question (I took the freedom to add it). $\endgroup$ Nov 21 at 11:17
  • 1
    $\begingroup$ That seems to be most likely because every chain part is at the same location (world origin) $\endgroup$
    – lemon
    Nov 21 at 11:32
  • 1
    $\begingroup$ Same here, the code works as expected. There is something else specific to your objects setup $\endgroup$
    – lemon
    Nov 21 at 11:43
  • 1
    $\begingroup$ could you share your file? that will help to try to see what is happening here $\endgroup$
    – lemon
    Nov 21 at 12:04

0

You must log in to answer this question.

Browse other questions tagged .