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.


1 Answer 1


Swap A and B

For the most part, blender works the other way. The last selected object is the active object,aka the context.object or context.active_object used by operators. An attribute of the context object can be assinged to all the other selected objects, in the list context.selected_objects

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)

import bpy
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.

  • $\begingroup$ How would you change this to get all x,y,z dimensions to be the same length? $\endgroup$ Aug 25, 2019 at 1:49
  • $\begingroup$ ob.dimensions = (x,) * 3 $\endgroup$
    – batFINGER
    Aug 25, 2019 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .