91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import bpy
|
|
import os
|
|
|
|
from bpy.props import (FloatProperty,
|
|
BoolProperty,
|
|
EnumProperty,
|
|
StringProperty,
|
|
IntProperty,
|
|
PointerProperty,
|
|
FloatVectorProperty)
|
|
|
|
from bpy.app.handlers import persistent
|
|
|
|
# region Preferences
|
|
|
|
class RT_prefs(bpy.types.AddonPreferences):
|
|
bl_idname = __package__
|
|
|
|
use_env_base_path_templates : BoolProperty(
|
|
name="Use Environment Base Path Templates",
|
|
description="Use environmenet variables to set base path for file output templates\
|
|
\nFollowing env variable are available:\
|
|
\nRENDERTOOLBOX_EXR_PATH_TEMPLATE fo single base path file output\
|
|
\nRENDERTOOLBOX_MULTILAYER_PATH_TEMPLATE for multilayer base path file output",
|
|
default=True,
|
|
)
|
|
|
|
base_path_template: StringProperty(
|
|
name="Base Path Template",
|
|
description="Template for base paths",
|
|
default="//render/{node_label}/",
|
|
)
|
|
|
|
base_path_multilayer_template: StringProperty(
|
|
name="Base Path Multilayer Template",
|
|
description="Template for base paths of multilayer files",
|
|
default="//render/{node_label}/{node_label}_",
|
|
)
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
layout.use_property_split = True
|
|
layout.use_property_decorate = False
|
|
|
|
layout.prop(self, "use_env_base_path_templates", text="Use Environment Base Path Templates")
|
|
col = layout.column()
|
|
# col.active = not self.use_env_base_path_templates
|
|
col.prop(self, "base_path_template", text="Base Path Template")
|
|
col.prop(self, "base_path_multilayer_template", text="Base Path Multilayer Template")
|
|
|
|
if self.use_env_base_path_templates:
|
|
col.separator()
|
|
col.label(text="Environment variables will override above templates if set", icon='INFO')
|
|
# col.label(text="RENDERTOOLBOX_EXR_PATH_TEMPLATE for single base path file output")
|
|
# col.label(text="RENDERTOOLBOX_MULTILAYER_PATH_TEMPLATE for multilayer base path file output")
|
|
col.label(text='If environment variables are not found, preferences will be used instead')
|
|
|
|
|
|
# region Handlers
|
|
|
|
@persistent
|
|
def set_render_toolbox_settings(dummy):
|
|
## Handler for prefs to scene properties replications
|
|
from .properties import reset_scene_path_templates
|
|
reset_scene_path_templates()
|
|
|
|
# region Register
|
|
|
|
classes = (
|
|
RT_prefs,
|
|
)
|
|
|
|
def register():
|
|
for cls in classes:
|
|
bpy.utils.register_class(cls)
|
|
|
|
# prefs = bpy.context.preferences.addons[__package__].preferences
|
|
|
|
if not 'set_render_toolbox_settings' in [hand.__name__ for hand in bpy.app.handlers.load_post]:
|
|
bpy.app.handlers.load_post.append(set_render_toolbox_settings)
|
|
|
|
def unregister():
|
|
if not 'set_render_toolbox_settings' in [hand.__name__ for hand in bpy.app.handlers.load_post]:
|
|
bpy.app.handlers.load_post.remove(set_render_toolbox_settings)
|
|
|
|
for cls in reversed(classes):
|
|
bpy.utils.unregister_class(cls)
|
|
|
|
# endregion |