Align Openpype and Ayon settings, quick fix in shelves loader script

This commit is contained in:
MustafaJafar 2023-11-01 12:29:41 +02:00
parent 0e331db93a
commit 381c00c334
3 changed files with 91 additions and 73 deletions

View file

@ -23,29 +23,33 @@ def generate_shelves():
# load configuration of houdini shelves # load configuration of houdini shelves
project_name = get_current_project_name() project_name = get_current_project_name()
project_settings = get_project_settings(project_name) project_settings = get_project_settings(project_name)
shelves_set_config = project_settings["houdini"]["shelves"] shelves_configs = project_settings["houdini"]["shelves"]
if not shelves_set_config: if not shelves_configs:
log.debug("No custom shelves found in project settings.") log.debug("No custom shelves found in project settings.")
return return
# Get Template data # Get Template data
template_data = get_current_context_template_data() template_data = get_current_context_template_data()
for shelf_set_config in shelves_set_config: for config in shelves_configs:
shelf_set_filepath = shelf_set_config.get('shelf_set_source_path') selected_option = config["options"]
shelf_set_os_filepath = shelf_set_filepath[current_os] shelf_set_config = config[selected_option]
if shelf_set_os_filepath:
shelf_set_os_filepath = get_path_using_template_data(
shelf_set_os_filepath, template_data
)
if not os.path.isfile(shelf_set_os_filepath):
log.error("Shelf path doesn't exist - "
"{}".format(shelf_set_os_filepath))
continue
hou.shelves.loadFile(shelf_set_os_filepath) shelf_set_filepath = shelf_set_config.get('shelf_set_source_path')
continue if shelf_set_filepath:
shelf_set_os_filepath = shelf_set_filepath[current_os]
if shelf_set_os_filepath:
shelf_set_os_filepath = get_path_using_template_data(
shelf_set_os_filepath, template_data
)
if not os.path.isfile(shelf_set_os_filepath):
log.error("Shelf path doesn't exist - "
"{}".format(shelf_set_os_filepath))
continue
hou.shelves.loadFile(shelf_set_os_filepath)
continue
shelf_set_name = shelf_set_config.get('shelf_set_name') shelf_set_name = shelf_set_config.get('shelf_set_name')
if not shelf_set_name: if not shelf_set_name:

View file

@ -15,11 +15,18 @@
"label": "Add a .shelf file", "label": "Add a .shelf file",
"children": [ "children": [
{ {
"type": "path", "type": "dict",
"key": "shelf_set_source_path", "key": "add_shelf_file",
"label": "Shelf Set Path", "label": "Add a .shelf file",
"multipath": false, "children": [
"multiplatform": true {
"type": "path",
"key": "shelf_set_source_path",
"label": "Shelf Set Path",
"multipath": false,
"multiplatform": true
}
]
} }
] ]
}, },
@ -28,60 +35,67 @@
"label": "Add Shelf Set Name and Shelves Definitions", "label": "Add Shelf Set Name and Shelves Definitions",
"children": [ "children": [
{ {
"type": "text", "key": "add_set_and_definitions",
"key": "shelf_set_name", "label": "Add Shelf Set Name and Shelves Definitions",
"label": "Shelf Set Name" "type": "dict",
}, "children": [
{ {
"type": "list", "type": "text",
"key": "shelf_definition", "key": "shelf_set_name",
"label": "Shelves Definitions", "label": "Shelf Set Name"
"use_label_wrap": true, },
"object_type": { {
"type": "dict", "type": "list",
"children": [ "key": "shelf_definition",
{ "label": "Shelves Definitions",
"type": "text", "use_label_wrap": true,
"key": "shelf_name", "object_type": {
"label": "Shelf Name" "type": "dict",
}, "children": [
{ {
"type": "list", "type": "text",
"key": "tools_list", "key": "shelf_name",
"label": "Tools", "label": "Shelf Name"
"use_label_wrap": true, },
"object_type": { {
"type": "dict", "type": "list",
"children": [ "key": "tools_list",
{ "label": "Tools",
"type": "label", "use_label_wrap": true,
"label": "Name and Script Path are mandatory." "object_type": {
}, "type": "dict",
{ "children": [
"type": "text", {
"key": "label", "type": "label",
"label": "Name" "label": "Name and Script Path are mandatory."
}, },
{ {
"type": "path", "type": "text",
"key": "script", "key": "label",
"label": "Script" "label": "Name"
}, },
{ {
"type": "path", "type": "path",
"key": "icon", "key": "script",
"label": "Icon" "label": "Script"
}, },
{ {
"type": "text", "type": "path",
"key": "help", "key": "icon",
"label": "Help" "label": "Icon"
},
{
"type": "text",
"key": "help",
"label": "Help"
}
]
} }
] }
} ]
} }
] }
} ]
} }
] ]
} }

View file

@ -30,7 +30,7 @@ class AddShelfFileModel(BaseSettingsModel):
class AddSetAndDefinitionsModel(BaseSettingsModel): class AddSetAndDefinitionsModel(BaseSettingsModel):
shelf_set_name: str = Field(title="Shelf Set Name") shelf_set_name: str = Field("", title="Shelf Set Name")
shelf_definition: list[ShelfDefinitionModel] = Field( shelf_definition: list[ShelfDefinitionModel] = Field(
default_factory=list, default_factory=list,
title="Shelves Definitions" title="Shelves Definitions"