Added settings to make optional the setting the unit scale

This commit is contained in:
Simone Barbieri 2023-05-18 10:37:38 +01:00
parent 3350e0995f
commit d95299a31b
3 changed files with 50 additions and 11 deletions

View file

@ -124,19 +124,34 @@ def set_start_end_frames():
scene.render.resolution_y = resolution_y
def set_base_file_unit_scale():
def on_new():
set_start_end_frames()
project = os.environ.get("AVALON_PROJECT")
settings = get_project_settings(project)
unit_scale = settings.get("blender").get("base_file_unit_scale")
bpy.context.scene.unit_settings.scale_length = unit_scale
unit_scale_settings = settings.get("blender").get("unit_scale_settings")
unit_scale_enabled = unit_scale_settings.get("enabled")
if unit_scale_enabled:
unit_scale = unit_scale_settings.get("base_file_unit_scale")
bpy.context.scene.unit_settings.scale_length = unit_scale
def on_new():
def on_open():
set_start_end_frames()
set_base_file_unit_scale()
project = os.environ.get("AVALON_PROJECT")
settings = get_project_settings(project)
unit_scale_settings = settings.get("blender").get("unit_scale_settings")
unit_scale_enabled = unit_scale_settings.get("enabled")
apply_on_opening = unit_scale_settings.get("apply_on_opening")
if unit_scale_enabled and apply_on_opening:
unit_scale = unit_scale_settings.get("base_file_unit_scale")
prev_unit_scale = bpy.context.scene.unit_settings.scale_length
if unit_scale != prev_unit_scale:
bpy.context.scene.unit_settings.scale_length = unit_scale
def on_open():
set_start_end_frames()

View file

@ -1,5 +1,9 @@
{
"base_file_unit_scale": 0.01,
"unit_scale_settings": {
"enabled": true,
"apply_on_opening": false,
"base_file_unit_scale": 0.01
},
"imageio": {
"ocio_config": {
"enabled": false,

View file

@ -6,10 +6,30 @@
"is_file": true,
"children": [
{
"key": "base_file_unit_scale",
"type": "number",
"label": "Base File Unit Scale",
"decimal": 2
"key": "unit_scale_settings",
"type": "dict",
"label": "Set Unit Scale",
"collapsible": true,
"is_group": true,
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"key": "apply_on_opening",
"type": "boolean",
"label": "Apply on Opening Existing Files"
},
{
"key": "base_file_unit_scale",
"type": "number",
"label": "Base File Unit Scale",
"decimal": 2
}
]
},
{
"key": "imageio",