# Why does my object offset when setting its parent with Python? [duplicate]

By using

bpy.data.objects['object1'].parent = bpy.data.objects['object2']


to parent one object to another the parented object gets a weird offset. Why does this happen and how can i fix this?

• I asked a similar question before: blender.stackexchange.com/questions/62897/… The method you are using is equivalent to assigning the parent in the "Relations" section. This causes mesh to change location. The other way is using CTRL-P to do the parenting. It looks like the Python code might be: bpy.ops.object.parent_set(...) – TTTTTTa Nov 14 '16 at 19:35
• It would be nice if they could eliminate the 5-minute rule for editing comments on this site. Not sure the reasoning behind this. Anyway, here is a link to another questions which looks like it has an explanation to the code: blender.stackexchange.com/questions/26108/… – TTTTTTa Nov 14 '16 at 19:44
• Possible dupe of blender.stackexchange.com/a/29148/15543 – batFINGER Nov 15 '16 at 10:09