mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
quick dump
This commit is contained in:
parent
f07e0a31a4
commit
39c5bcac10
3 changed files with 35 additions and 23 deletions
|
|
@ -1033,9 +1033,10 @@ def get_container_transforms(container, members=None, root=False):
|
|||
Args:
|
||||
container (dict): the container
|
||||
members (list): optional and convenience argument
|
||||
root (bool): return highest node in hierachy if True
|
||||
|
||||
Returns:
|
||||
root (list / str): highest node in hierarchy
|
||||
root (list / str):
|
||||
"""
|
||||
|
||||
if not members:
|
||||
|
|
@ -1043,6 +1044,8 @@ def get_container_transforms(container, members=None, root=False):
|
|||
|
||||
results = cmds.ls(members, type="transform", long=True)
|
||||
if root:
|
||||
results = core.getHighestInHierarchy(results)[0]
|
||||
root = core.getHighestInHierarchy(results)
|
||||
if root:
|
||||
results = root[0]
|
||||
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ class CollectSetDress(pyblish.api.InstancePlugin):
|
|||
containers = amaya.ls()
|
||||
|
||||
# Get all content from the instance
|
||||
topnode = cmds.sets(instance.name, query=True)[0]
|
||||
instance_lookup = set(cmds.ls(instance, type="transform", long=True))
|
||||
data = defaultdict(list)
|
||||
|
||||
for container in containers:
|
||||
hierarchy_nodes = []
|
||||
for i, container in enumerate(containers):
|
||||
members = cmds.sets(container["objectName"], query=True)
|
||||
transforms = lib.get_container_transforms(container, members)
|
||||
root = lib.get_container_transforms(container,
|
||||
|
|
@ -39,25 +41,35 @@ class CollectSetDress(pyblish.api.InstancePlugin):
|
|||
if root not in instance_lookup:
|
||||
continue
|
||||
|
||||
# retrieve all matrix data
|
||||
matrix_data = self.get_matrix_data(sorted(transforms))
|
||||
# Retrieve all matrix data
|
||||
hierarchy = cmds.listRelatives(root, parent=True, fullPath=True)[0]
|
||||
relative_hierarchy = hierarchy.replace(topnode, "*")
|
||||
hierarchy_nodes.append(relative_hierarchy)
|
||||
|
||||
# Gather info for new data entry
|
||||
reference_node = cmds.ls(members, type="reference")[0]
|
||||
namespace = cmds.referenceQuery(reference_node, namespace=True)
|
||||
representation_id = container["representation"]
|
||||
data[representation_id].append({
|
||||
"loader": container["loader"],
|
||||
"matrix": matrix_data,
|
||||
"namespace": namespace.strip(":")
|
||||
})
|
||||
|
||||
instance_data = {"loader": container["loader"],
|
||||
"hierarchy": hierarchy,
|
||||
"namespace": namespace.strip(":")}
|
||||
|
||||
# Check if matrix differs from default and store changes
|
||||
matrix_data = self.get_matrix_data(root)
|
||||
if matrix_data:
|
||||
instance_data["matrix"] = matrix_data
|
||||
|
||||
data[representation_id].append(instance_data)
|
||||
|
||||
instance.data["scenedata"] = dict(data)
|
||||
instance.data["hierarchy"] = list(set(hierarchy_nodes))
|
||||
|
||||
|
||||
def get_file_rule(self, rule):
|
||||
return mel.eval('workspace -query -fileRuleEntry "{}"'.format(rule))
|
||||
|
||||
def get_matrix_data(self, members):
|
||||
def get_matrix_data(self, node):
|
||||
"""Get the matrix of all members when they are not default
|
||||
|
||||
Each matrix which differs from the default will be stored in a
|
||||
|
|
@ -69,11 +81,8 @@ class CollectSetDress(pyblish.api.InstancePlugin):
|
|||
dict
|
||||
"""
|
||||
|
||||
matrix_data = {}
|
||||
for idx, member in enumerate(members):
|
||||
matrix = cmds.xform(member, query=True, matrix=True)
|
||||
if matrix == lib.DEFAULT_MATRIX:
|
||||
continue
|
||||
matrix_data[idx] = matrix
|
||||
matrix = cmds.xform(node, query=True, matrix=True)
|
||||
if matrix == lib.DEFAULT_MATRIX:
|
||||
return
|
||||
|
||||
return matrix_data
|
||||
return matrix
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class ExtractSetDress(colorbleed.api.Extractor):
|
|||
def process(self, instance):
|
||||
|
||||
parent_dir = self.staging_dir(instance)
|
||||
filename = "{}.abc".format(instance.name)
|
||||
path = os.path.join(parent_dir, filename)
|
||||
hierarchy_filename = "{}.abc".format(instance.name)
|
||||
hierarchy_path = os.path.join(parent_dir, hierarchy_filename)
|
||||
json_filename = "{}.json".format(instance.name)
|
||||
json_path = os.path.join(parent_dir, json_filename)
|
||||
|
||||
|
|
@ -33,10 +33,10 @@ class ExtractSetDress(colorbleed.api.Extractor):
|
|||
json.dump(instance.data["scenedata"], filepath, ensure_ascii=False)
|
||||
|
||||
self.log.info("Extracting point cache ..")
|
||||
cmds.select(instance)
|
||||
cmds.select(cmds.ls(instance.data["hierarchy"], long=True))
|
||||
|
||||
# Run basic alembic exporter
|
||||
extract_alembic(file=path,
|
||||
extract_alembic(file=hierarchy_path,
|
||||
startFrame=1.0,
|
||||
endFrame=1.0,
|
||||
**{"step": 1.0,
|
||||
|
|
@ -46,7 +46,7 @@ class ExtractSetDress(colorbleed.api.Extractor):
|
|||
"uvWrite": True,
|
||||
"selection": True})
|
||||
|
||||
instance.data["files"] = [json_path, path]
|
||||
instance.data["files"] = [json_path, hierarchy_path]
|
||||
|
||||
# Remove data
|
||||
instance.data.pop("scenedata", None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue