'Size of object in Blender not correct,

Why is the length 1221.21' and not 192' as excepted. I am using Ubuntu 21.10 Linux and Blender 3.0 and scripting using Python. As can be seen from the 'scene properties' on the right the units are set to 'Imperial' not metric and should be in inches and feet. I am also using the orthogonal view and not perspective.

import bpy
tall = 7
inchesinfeet = 12
#horizontal pieces
length = 192
 #x
width = 4 #y
height = 2 #z
#vertical pieces
thick = 2 #x
wide = 2 #y
ceiling = tall*inchesinfeet #z
oncenter = 18

# bottom
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align='WORLD', location=(length/2, 0, 0), scale=(length, 1, 1))

# sides left first
print("length = " + str(length))
'''
bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(width, depth,) (tall*inchesinfeet+2*height)), scale=(width, depth, ))

bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(2 + 1*oncenter, 4, 98), scale=(depth, 

enter image description here

And the terminal output is as expected also

enter image description here



Solution 1:[1]

I tried your script and I am seeing size of cube as below. I think it is as expected, given scale(length,1,1) in script.

To see size of object, press 'N' to see dimensions as in this screenshot (Bottom right - we can see 384,2,2):enter image description here

Solution 2:[2]

Why is the length 1221.21' and not 192' as expected ?

because the operator bpy.ops.mesh.primitive_cube_add do not support imperial metric, and create your object using the 'none' metric, which in Blender is the same as for meters. Remember the Blender notation through the interface, eg for 1.02:

  • 1.02 is None

  • 1.02m is Meter

  • 1.02' is Imperial

Could you provide 1.02' to the operator ? No, the operator do not support this notation.

REF: Blender Mesh Operator : bpy.ops.mesh.primitive_cube_add

Programaticaly, whatever system unit in use, you have to provide the measure (size, scale, ..) of your object in 'none' metric. So, you have to convert from 'feet' to 'none'.

If you want a Cube of 192' :

1' = 0.3048m

Convert 192' to 'none' (ie 'meter') = 58.5216

Create your object using 58.5216 as parameter (size, scale, whatever)

That's all.

Some explanation: if you create a Cube 'by hand' - ie through the interface - you see that the Size parameter of your object is suffixed with the system metric unit notation currently in use (eg None = "", meter = m, imperial = ').

Through the interface, you can use the unit notation (m or ') according to your needs, and whatever unit system in use, you can enter different unit notations to specify the object size, even a mix of them (with some limitation).

So, you can enter '1.08m' in the size field, even if you use the Imperial unit system, Blender will convert it automatically. When you use the bpy operator, you cannot specify the unit notation like through the interface. So, the default 'None' (or Meter) is used.

The 'Unit settings' is a way to:

  • display the same object size using different unit scale
  • using a default unit system as parameter through the interface.

But IS NOT a way to compute using a default unit, because the operator do not support unit system notation, and all of the vertex vectors are in 'none/meter' metrics ; to display what is behind the scene on a modified default cube:

import bpy
print("Unit System In Use: " + bpy.context.scene.unit_settings.system)
for item in bpy.data.objects:
    print(item.name)
    if item.type == 'MESH':
        for vertex in item.data.vertices:
            print(vertex.co)

could output something like:

Unit System In Use: IMPERIAL
Camera
Cube
<Vector (3.3311, 1.3453, 1.0000)>
<Vector (1.0000, 1.0000, -1.0000)>
<Vector (1.0000, -1.0000, 1.0000)>
<Vector (1.0000, -1.0000, -1.0000)>
<Vector (-1.0000, 1.0000, 1.0000)>
<Vector (-1.0000, 1.0000, -1.0000)>
<Vector (-1.0000, -1.0000, 1.0000)>
<Vector (-1.0000, -1.0000, -1.0000)

The first vector display the vertex coordinate which is located at:

10.9287ft, 4.41385ft, 3.28084ft

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Deepak Garud
Solution 2