6
$\begingroup$

How can I copy dimensions of the first object and paste them onto the second bigger cushion so that they become identical, whithout having to copy and paste single dimensions on the n-bar?

cushion

$\endgroup$
0

2 Answers 2

10
$\begingroup$

If you enable Align Tools Add-on in the Preferences(F4->P, or Edit -> Preferences):

enter image description here

You will have Advanced button in the sidebar, Item tab:

enter image description here

You can then select the objects you want to scale, then select the one you wish to scale to so it's the last selected and active and hit Advanced under Advanced Align Operations:

enter image description here

In the Last Operation panel you will have Fit Dimensions:

enter image description here

$\endgroup$
2
  • $\begingroup$ This is an EXCELLENT add on. This was a quick and easy solution. Thank you! $\endgroup$
    – Partack
    Commented Jun 10, 2022 at 7:24
  • $\begingroup$ Perfect. Sadly Fit Dimensions is hidden under advanced. But good to know, it is there. $\endgroup$ Commented Jul 28 at 16:03
4
$\begingroup$

Python console

Can get and set most properties via the python console. D.objects (or bpy.data.objects) is all objects in the file.

To set the dimensions of an object named "Cube" to that of an object named "Test"

>>> D.objects['Cube'].dimensions = D.objects['Test'].dimensions 

The data defines the dimensions.

A mesh object in blender can have 0, 1, 2 or 3 dimensions.

Setting dimensions sets the scale based on the size of the bounding box. The box can have 0 to 3 dimensions.

Some examples.

  • 0D : A single vert or multiple verts at one location.

  • 1D : An axis aligned edge or edges if on same line.

  • 2D : Planes aligned to two axes. (Eg default Plane, XY plane at z=0)

  • 3D : None of the above. Eg default Cube.

Can only set the dimensions equally if they have the same number of mesh dimensions. For example cube has dimensions (2, 2, 2) and plane (2, 2, 0). Can set the cube to dimensions of plane, but not plane to dimensions of cube.

Note: scaling in edit mode to zero causes untold unwanted issues.

Hence some kind of rule of what to do going down is required.

Test script, sets all non zero dimensions of selected objects to non zero dimensions of active object.

import bpy
context = bpy.context

TOL = 1e-6

ob = context.active_object
dims = set(a for a in "xyz" if getattr(ob.dimensions, a, 0) >= TOL)

for o in context.selected_objects:
    if o is ob or o.type != 'MESH':
        continue
    
    p = "".join(dims.intersection(set(a for a in "xyz" if getattr(o.dimensions, a, 0) >= TOL)))
    setattr(o.dimensions, p, getattr(ob.dimensions, p))

ie if run with plane as active object will only set the "xy" dimensions of selected object o.dimensions.xy = ob.dimensions.xy , only when the object has an "x" or "y" dimension.

This test script can be made into an operator, and assigned a shortcut.

Align Tools

As noted in other answer can use the operator available in align tools. Once enabled,

The advanced operator, to fit X, Y and Z can be called from the console via

>>> bpy.ops.object.align_tools(fit_x=True, fit_y=True, fit_z=True)
{'FINISHED'}

Which can be made into a shortcut via UI, by pasting object.align_tools into keymap identifier field, press enter to expand the operator options, then check the appropriate "fit" boxes as shown.

enter image description here

Example added as CtrlShiftV in view3d object mode global keymap.

$\endgroup$

You must log in to answer this question.

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