3
$\begingroup$

When using python bpy I can change the default "view" units to cm:

bpy.context.scene.unit_settings.length_unit = 'CENTIMETERS' 

However, all the input is still in meters. For example if I change the camera location to:

cam.location = [0, 0, 5]

Blender thinks it's 5 meters ie 500 centimeters and not 5 centimeters.

enter image description here

How can I change the "bpy" settings to understand I'm using centimeters?

$\endgroup$
2
  • $\begingroup$ I think it's not possible, you can just use 0.05 $\endgroup$
    – Karan
    Commented Feb 19, 2023 at 6:39
  • $\begingroup$ Thanks for the input @Karan - looking for a more permanent solution though, as this will get annoying with 100+ objects $\endgroup$
    – nammerkage
    Commented Feb 19, 2023 at 9:41

1 Answer 1

5
$\begingroup$

Use unit_settings.scale_length link to convert between blender units and dimensions.

import bpy
bpy.context.scene.unit_settings.scale_length = 0.01
bpy.context.scene.unit_settings.length_unit = 'CENTIMETERS' 
cam = bpy.context.object
cam.location = [0, 0, 5]

enter image description here

$\endgroup$

You must log in to answer this question.

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