I require some help please. I select one object (A), then shift to select another (B). Then I require some python code to copy the X dimension from (A) to (B). The X dimensions for both objects are the same after the script is run.
Swap A and B
For the most part, blender works the other way. The last selected object is the active object,aka the
context.active_object used by operators. An attribute of the context object can be assinged to all the other selected objects, in the list
Hence select B [C, D, E, F...] then A, A has context. The x dimension of A is set as the X dimension of B and other non active selected objects. (and lazily A too not that it matters in this case as it is same)
context = bpy.context
x = context.object.dimensions.x
for o in context.selected_objects:
o.dimensions.x = x
Note: if an objects data has a zero dimension, for instance default plane in Z. there is no way of scaling to make its z dimension non zero.