I am trying to write a simple code that should perform the same action on all selected objects in Blender. For example, let's assume that I have two MESH objects in my scene and I want to print the scale along the x-axis of these two "MESH" objects. Here the code:
import bpy
objects = bpy.context.scene.objects
for obj in objects:
obj.select_set(obj.type == "MESH")
selected_objects = bpy.context.selected_objects
for cube in selected_objects:
print(bpy.context.object.scale[0])
The problem is that the code prints twice the same value, which refers to the last selected object (the one with the light yellow border). I can't understand why.