I am a more or less skilled Python user in Maya for quite some time and wanted to look into Python within Blender (Version: 2.79).
This is my code:
def posRotSclObj(): sel = bpy.context.selected_objects sel2 = sel sel1 = sel print(sel1) print(sel2) pos1 = sel1.location rot1 = sel1.rotation_euler scl1 = sel1.scale print (scl1) pos2 = sel2.delta_location sel2.location = (pos1, pos1, pos1) sel2.rotation_euler = (rot1, rot1, rot1) sel2.scale = (scl1, scl1, scl1) posRotSclObj()
I have 3 problems right now:
When I define my selection by
sel = bpy.context.selected_objectsthen
selis the second object I have selected and
selthe first...that's pretty counterintuitive, especially because it was the other way around in Maya. Is this right?
print selwould work in Maya but Blender needs brackets around my variable:
print (sel). Why is there difference in syntax?
When I indent beginning from the line after
defexcept for the last where I call my function and paste it into the python console within Blender it gives me indentation errors on every line that has one indent.