mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 17:04:54 +01:00
maya.plugins.pointcache Fix togglable flags defaults and adapt to new settings names
We weren't setting defaults when some admin defined flag was added to the toggleable flags, this commit will now pre-select those. It also adapts to the (hopefully) better named settings for the Alembic export.
This commit is contained in:
parent
8e284aaa4d
commit
265239770e
2 changed files with 71 additions and 60 deletions
|
|
@ -17,8 +17,8 @@ from openpype.pipeline import CreatedInstance
|
|||
def _get_animation_attr_defs(cls):
|
||||
"""Get Animation generic definitions.
|
||||
|
||||
The line is blurry between what's "Animation" generic and "Alembic" is
|
||||
blurry, but the rule of thumb is that whatever "AlembicExport -h" accepts
|
||||
The line is blurry between what's "Animation" generic and "Alembic",
|
||||
but the rule of thumb is that whatever "AlembicExport -h" accepts
|
||||
is "Alembic" and the other ones are "Animation".
|
||||
"""
|
||||
defs = lib.collect_animation_defs()
|
||||
|
|
@ -36,37 +36,41 @@ def _get_animation_attr_defs(cls):
|
|||
return defs
|
||||
|
||||
|
||||
def _get_alembic_boolean_arguments(cls):
|
||||
"""Get two sets with the Alembic flags.
|
||||
def _get_abc_export_flags(cls):
|
||||
"""Get two sets with the Alembic Export flags.
|
||||
|
||||
Alembic flags are treted as booleans, so here we get all the possible
|
||||
options, and work out a list with all the ones that can be toggled and the
|
||||
list of defaults (un-toggleable.)
|
||||
Alembic flags are treated as booleans, so here we get all the possible
|
||||
options, and work out a list with all the ones that can be toggled by
|
||||
the user, and the ones defined in the settings.
|
||||
"""
|
||||
all_alembic_booleans = {
|
||||
|
||||
# The Arguments that can be modified by the Publisher
|
||||
abc_export_overrides = set(getattr(cls, "abc_export_overrides", set()))
|
||||
|
||||
# What we have set in the Settings as defaults.
|
||||
default_abc_export_flags = set(getattr(cls, "abc_export_flags", set()))
|
||||
|
||||
# Set of un-toggleable flags, specified by the settings
|
||||
abc_export_flags = {
|
||||
arg
|
||||
for arg in default_abc_export_flags
|
||||
if arg not in abc_export_overrides
|
||||
}
|
||||
|
||||
# Set of all the available Alembic Export Flags
|
||||
abc_boolean_flags = {
|
||||
arg
|
||||
for arg, arg_type in ALEMBIC_ARGS.items()
|
||||
if arg_type is bool
|
||||
}
|
||||
|
||||
# The Arguments that can be modified by the Publisher
|
||||
abc_args_overrides = set(getattr(cls, "abc_args_overrides", set()))
|
||||
|
||||
# What we have set in the Settings as defaults.
|
||||
abc_settings_boolean_args = set(getattr(cls, "abc_boolean_args", set()))
|
||||
|
||||
abc_boolean_args = {
|
||||
# Set of togglable flags
|
||||
abc_export_toggleable_flags = {
|
||||
arg
|
||||
for arg in abc_settings_boolean_args
|
||||
if arg not in abc_args_overrides
|
||||
for arg in abc_export_overrides
|
||||
if arg in abc_boolean_flags
|
||||
}
|
||||
|
||||
abc_args_overrides = {
|
||||
arg
|
||||
for arg in abc_args_overrides
|
||||
if arg in all_alembic_booleans
|
||||
}
|
||||
return abc_boolean_args, abc_args_overrides
|
||||
return abc_export_flags, abc_export_toggleable_flags
|
||||
|
||||
|
||||
def _get_animation_abc_attr_defs(cls):
|
||||
|
|
@ -98,16 +102,19 @@ def _get_animation_abc_attr_defs(cls):
|
|||
# The Arguments that can be modified by the Publisher
|
||||
abc_args_overrides = getattr(cls, "abc_args_overrides", None)
|
||||
|
||||
# What we have set in the Settings as defaults.
|
||||
default_abc_export_flags = set(getattr(cls, "abc_export_flags", set()))
|
||||
|
||||
(
|
||||
abc_boolean_defaults,
|
||||
abc_boolean_overrides,
|
||||
) = _get_alembic_boolean_arguments(cls)
|
||||
abc_export_flags,
|
||||
abc_export_toggleable_flags,
|
||||
) = _get_abc_export_flags(cls)
|
||||
|
||||
abc_defs.append(
|
||||
EnumDef(
|
||||
"abcDefaultExportBooleanArguments",
|
||||
list(abc_boolean_defaults),
|
||||
default=list(abc_boolean_defaults),
|
||||
"abcExportFlags",
|
||||
list(abc_export_flags),
|
||||
default=list(abc_export_flags),
|
||||
multiselection=True,
|
||||
label="Settings Defined Arguments",
|
||||
disabled=True,
|
||||
|
|
@ -116,13 +123,18 @@ def _get_animation_abc_attr_defs(cls):
|
|||
)
|
||||
|
||||
# Only display Boolan flags that the Admin defined as overrideable
|
||||
abc_export_toggleable_defaults = [
|
||||
for arg in abc_export_toggleable_flags
|
||||
if arg in default_abc_export_flags
|
||||
]
|
||||
abc_defs.append(
|
||||
EnumDef(
|
||||
"abcExportBooleanArguments",
|
||||
list(abc_boolean_overrides) if abc_boolean_overrides else [""],
|
||||
"abcExportTogglableFlags",
|
||||
list(abc_export_toggleable_flags) if abc_export_toggleable_flags else [""],
|
||||
default=abc_export_toggleable_defaults,
|
||||
multiselection=True,
|
||||
label="Arguments Overrides",
|
||||
disabled=True if not abc_boolean_overrides else False,
|
||||
label="Export Flags",
|
||||
disabled=True if not abc_export_toggleable_flags else False,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -204,14 +216,14 @@ def _ensure_defaults(cls, instance_data):
|
|||
(
|
||||
abc_boolean_defaults,
|
||||
abc_boolean_overrides,
|
||||
) = _get_alembic_boolean_arguments(cls)
|
||||
) = _get_abc_export_flags(cls)
|
||||
|
||||
creator_attr["abcDefaultExportBooleanArguments"] = list(abc_boolean_defaults)
|
||||
creator_attr["abcExportFlags"] = list(abc_boolean_defaults)
|
||||
|
||||
if creator_attr.get("abcExportBooleanArguments", []):
|
||||
abc_boolean_args = creator_attr["abcExportBooleanArguments"].copy()
|
||||
if creator_attr.get("abcExportTogglableFlags", []):
|
||||
abc_boolean_args = creator_attr["abcExportTogglableFlags"].copy()
|
||||
|
||||
creator_attr["abcExportBooleanArguments"] = [
|
||||
creator_attr["abcExportTogglableFlags"] = [
|
||||
arg for arg in abc_boolean_args
|
||||
if arg not in abc_boolean_overrides
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ import os
|
|||
from maya import cmds
|
||||
|
||||
from openpype.pipeline import publish
|
||||
from openpype.hosts.maya.api.alembic import ALEMBIC_ARGS, extract_alembic
|
||||
from openpype.hosts.maya.api.alembic import extract_alembic
|
||||
from openpype.hosts.maya.api.lib import (
|
||||
suspended_refresh,
|
||||
maintained_selection,
|
||||
iter_visible_nodes_in_range
|
||||
iter_visible_nodes_in_range,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -40,14 +40,11 @@ class ExtractAlembic(publish.Extractor):
|
|||
# Collect Alembic Arguments
|
||||
creator_attributes = instance.data.get("creator_attributes")
|
||||
abc_flags = creator_attributes.get(
|
||||
"abcDefaultExportBooleanArguments"
|
||||
) + creator_attributes.get(
|
||||
"abcExportBooleanArguments"
|
||||
)
|
||||
"abcExportTogglableFlags"
|
||||
) + creator_attributes.get("abcExportTogglableFlags")
|
||||
|
||||
abc_attrs = [
|
||||
attr.strip()
|
||||
for attr in creator_attributes.get("attr", "").split(";")
|
||||
attr.strip() for attr in creator_attributes.get("attr", "").split(";")
|
||||
]
|
||||
|
||||
abc_attr_prefixes = [
|
||||
|
|
@ -88,7 +85,7 @@ class ExtractAlembic(publish.Extractor):
|
|||
"preRollStartFrame": creator_attributes.get("preRollStartFrame", 0),
|
||||
"renderableOnly": True if "renderableOnly" in abc_flags else False,
|
||||
"root": abc_root,
|
||||
"selection": True, # Should this stay like so?
|
||||
"selection": True, # Should this stay like so?
|
||||
"startFrame": start,
|
||||
"step": creator_attributes.get("step", 1.0),
|
||||
"stripNamespaces": True,
|
||||
|
|
@ -109,15 +106,17 @@ class ExtractAlembic(publish.Extractor):
|
|||
# flag does not filter out those that are only hidden on some
|
||||
# frames as it counts "animated" or "connected" visibilities as
|
||||
# if it's always visible.
|
||||
nodes = list(iter_visible_nodes_in_range(nodes,
|
||||
start=start,
|
||||
end=end))
|
||||
nodes = list(iter_visible_nodes_in_range(nodes, start=start, end=end))
|
||||
|
||||
suspend = not instance.data.get("refresh", False)
|
||||
with suspended_refresh(suspend=suspend):
|
||||
with maintained_selection():
|
||||
cmds.select(nodes, noExpand=True)
|
||||
self.log.debug("Running `extract_alembic` with the arguments: {}".format(extract_abc_args))
|
||||
self.log.debug(
|
||||
"Running `extract_alembic` with the arguments: {}".format(
|
||||
extract_abc_args
|
||||
)
|
||||
)
|
||||
extract_alembic(**extract_abc_args)
|
||||
|
||||
if "representations" not in instance.data:
|
||||
|
|
@ -127,7 +126,7 @@ class ExtractAlembic(publish.Extractor):
|
|||
"name": "abc",
|
||||
"ext": "abc",
|
||||
"files": filename,
|
||||
"stagingDir": dirname
|
||||
"stagingDir": dirname,
|
||||
}
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
|
|
@ -159,7 +158,7 @@ class ExtractAlembic(publish.Extractor):
|
|||
"ext": "abc",
|
||||
"files": os.path.basename(path),
|
||||
"stagingDir": dirname,
|
||||
"outputName": "proxy"
|
||||
"outputName": "proxy",
|
||||
}
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
|
|
@ -172,18 +171,18 @@ class ExtractAnimation(ExtractAlembic):
|
|||
families = ["animation"]
|
||||
|
||||
def get_members_and_roots(self, instance):
|
||||
|
||||
# Collect the out set nodes
|
||||
out_sets = [node for node in instance if node.endswith("out_SET")]
|
||||
if len(out_sets) != 1:
|
||||
raise RuntimeError("Couldn't find exactly one out_SET: "
|
||||
"{0}".format(out_sets))
|
||||
raise RuntimeError(
|
||||
"Couldn't find exactly one out_SET: " "{0}".format(out_sets)
|
||||
)
|
||||
out_set = out_sets[0]
|
||||
roots = cmds.sets(out_set, query=True)
|
||||
|
||||
# Include all descendants
|
||||
nodes = roots + cmds.listRelatives(roots,
|
||||
allDescendents=True,
|
||||
fullPath=True) or []
|
||||
nodes = (
|
||||
roots + cmds.listRelatives(roots, allDescendents=True, fullPath=True) or []
|
||||
)
|
||||
|
||||
return nodes, roots
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue