I'm modifying the Template -> Python -> Batch Export script to batch export a bunch of .glb files
During export I need to zero out the location of the object using -
bpy.ops.object.location_clear(clear_delta=False)
But, I want store the objects location before I zero them with this function - then restore it's location after the location is zero'd and exported. This is because I need the transforms zero'd out when I import them into another program.
I am new to python in blender, so I started by trying to print the location of the selected object with -
print(bpy.ops.object.location)
But even with this simple print statement, I'm stuck, as I can't get the script to print the actual x,y,z coordinates.
Can anybody help me out with the code for this? Thanks a bunch
bpy.opsare for interactive use through the UI and should be avoided in scripts because they depend on context. Using them through scripts may yield unexpected results at best, or fail entirely at worst. Manipulate data directly frombpy.datainstead. – Duarte Farrajota Ramos Oct 30 '23 at 22:46bpy.data.objects["your_object_name"].location. If you have a parent-child relationship this might be a little more complicated since you need to access the world matrix of your object instead. – Gorgious Oct 31 '23 at 06:05