mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
add offset when loading multiple subsets
This commit is contained in:
parent
a549634c0a
commit
e10343de2b
2 changed files with 26 additions and 9 deletions
|
|
@ -42,6 +42,11 @@ class ReferenceLoader(api.Loader):
|
|||
default=1,
|
||||
min=1,
|
||||
help="How many times to load?"
|
||||
),
|
||||
qargparse.Double3(
|
||||
"offset",
|
||||
label="Position Offset",
|
||||
help="Offset loaded models for easier selection."
|
||||
)
|
||||
]
|
||||
|
||||
|
|
@ -50,8 +55,7 @@ class ReferenceLoader(api.Loader):
|
|||
context,
|
||||
name=None,
|
||||
namespace=None,
|
||||
options=None,
|
||||
data=None
|
||||
options=None
|
||||
):
|
||||
|
||||
import os
|
||||
|
|
@ -64,19 +68,25 @@ class ReferenceLoader(api.Loader):
|
|||
loaded_containers = []
|
||||
|
||||
count = options.get("count") or 1
|
||||
while count > 0:
|
||||
count -= 1
|
||||
for c in range(0, count):
|
||||
namespace = namespace or lib.unique_namespace(
|
||||
asset["name"] + "_",
|
||||
prefix="_" if asset["name"][0].isdigit() else "",
|
||||
suffix="_",
|
||||
)
|
||||
|
||||
# Offset loaded subset
|
||||
if "offset" in options:
|
||||
offset = [i * c for i in options["offset"]]
|
||||
options["translate"] = offset
|
||||
|
||||
self.log.info(options)
|
||||
|
||||
self.process_reference(
|
||||
context=context,
|
||||
name=name,
|
||||
namespace=namespace,
|
||||
data=data
|
||||
options=options
|
||||
)
|
||||
|
||||
# Only containerize if any nodes were loaded by the Loader
|
||||
|
|
@ -91,6 +101,9 @@ class ReferenceLoader(api.Loader):
|
|||
context=context,
|
||||
loader=self.__class__.__name__
|
||||
))
|
||||
|
||||
c += 1
|
||||
namespace = None
|
||||
return loaded_containers
|
||||
|
||||
def process_reference(self, context, name, namespace, data):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import pype.maya.plugin
|
||||
reload(pype.maya.plugin)
|
||||
from avalon import api, maya
|
||||
from maya import cmds
|
||||
import os
|
||||
|
|
@ -24,7 +25,7 @@ class ReferenceLoader(pype.maya.plugin.ReferenceLoader):
|
|||
icon = "code-fork"
|
||||
color = "orange"
|
||||
|
||||
def process_reference(self, context, name, namespace, data):
|
||||
def process_reference(self, context, name, namespace, options):
|
||||
import maya.cmds as cmds
|
||||
from avalon import maya
|
||||
import pymel.core as pm
|
||||
|
|
@ -101,16 +102,19 @@ class ReferenceLoader(pype.maya.plugin.ReferenceLoader):
|
|||
cmds.setAttr(groupName + ".selectHandleY", cy)
|
||||
cmds.setAttr(groupName + ".selectHandleZ", cz)
|
||||
|
||||
if data.get("post_process", True):
|
||||
if "translate" in options:
|
||||
cmds.setAttr(groupName + ".t", *options["translate"])
|
||||
|
||||
if options.get("post_process", True):
|
||||
if family == "rig":
|
||||
self._post_process_rig(name, namespace, context, data)
|
||||
self._post_process_rig(name, namespace, context, options)
|
||||
|
||||
return newNodes
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
|
||||
def _post_process_rig(self, name, namespace, context, data):
|
||||
def _post_process_rig(self, name, namespace, context, options):
|
||||
|
||||
output = next((node for node in self if
|
||||
node.endswith("out_SET")), None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue