layout publish more than one container issue

This commit is contained in:
Kayla Man 2022-12-04 19:16:01 +08:00
parent 632ee268e1
commit d57fdcf797
2 changed files with 20 additions and 8 deletions

View file

@ -8,3 +8,10 @@ class CreateLayout(plugin.Creator):
label = "Layout"
family = "layout"
icon = "cubes"
def __init__(self, *args, **kwargs):
super(CreateLayout, self).__init__(*args, **kwargs)
# enable this when you want to
# publish group of loaded asset
self.data["groupLoadedAssets"] = False

View file

@ -38,14 +38,19 @@ class ExtractLayout(publish.Extractor):
container_list = cmds.ls(project_container)
assert len(container_list) == 1, \
"Please create instance with loaded asset!"
# list the children of the containers
grp_name = asset.split(':')[0]
container_sel = cmds.ls("{}*_CON".format(grp_name))
if not container_sel:
assert container_sel == [], \
"Use all loaded contents without renaming and grouping!" # noqa
for con in container_sel:
container = con
grp_loaded_ass = instance.data.get("groupLoadedAssets", False)
if grp_loaded_ass:
asset_list = cmds.listRelatives(asset, children=True)
for asset in asset_list:
grp_name = asset.split(':')[0]
else:
grp_name = asset.split(':')[0]
containers = cmds.ls("{}*_CON".format(grp_name))
assert len(containers) > 0, \
"Use all loaded contents without renaming" \
"(and/or grouping if groupLoadedAssets disabled)" # noqa
container = containers[0]
representation_id = cmds.getAttr(
"{}.representation".format(container))