mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
rename the loadOpenpypedata functions
This commit is contained in:
parent
5dde7a209b
commit
cf4ce6bbc5
9 changed files with 65 additions and 30 deletions
|
|
@ -174,16 +174,24 @@ def containerise(name: str, nodes: list, context, loader=None, suffix="_CON"):
|
|||
return container
|
||||
|
||||
|
||||
def load_OpenpypeData():
|
||||
"""Re-loading the Openpype parameter built by the creator
|
||||
def load_custom_attribute_data():
|
||||
"""Re-loading the Openpype/AYON custom parameter built by the creator
|
||||
|
||||
Returns:
|
||||
attribute: re-loading the custom OP attributes set in Maxscript
|
||||
"""
|
||||
return rt.Execute(MS_CUSTOM_ATTRIB)
|
||||
|
||||
|
||||
def import_OpenpypeData(container, selections):
|
||||
attrs = load_OpenpypeData()
|
||||
def import_custom_attribute_data(container: str, selections: list):
|
||||
"""Importing the Openpype/AYON custom parameter built by the creator
|
||||
|
||||
Args:
|
||||
container (str): target container which adds custom attributes
|
||||
selections (_type_): nodes to be added into
|
||||
group in custom attributes
|
||||
"""
|
||||
attrs = load_custom_attribute_data()
|
||||
modifier = rt.EmptyModifier()
|
||||
rt.addModifier(container, modifier)
|
||||
container.modifiers[0].name = "OP Data"
|
||||
|
|
@ -203,7 +211,14 @@ def import_OpenpypeData(container, selections):
|
|||
"sel_list", sel_list)
|
||||
|
||||
|
||||
def update_Openpype_Data(container, selections):
|
||||
def update_custom_attribute_data(container: str, selections: list):
|
||||
"""Updating the Openpype/AYON custom parameter built by the creator
|
||||
|
||||
Args:
|
||||
container (str): target container which adds custom attributes
|
||||
selections (_type_): nodes to be added into
|
||||
group in custom attributes
|
||||
"""
|
||||
if container.modifiers[0].name == "OP Data":
|
||||
rt.deleteModifier(container, container.modifiers[0])
|
||||
import_OpenpypeData(container, selections)
|
||||
import_custom_attribute_data(container, selections)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import os
|
|||
|
||||
from openpype.hosts.max.api import lib, maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ class FbxLoader(load.LoaderPlugin):
|
|||
|
||||
container = rt.container(name=name)
|
||||
selections = rt.GetCurrentSelection()
|
||||
import_OpenpypeData(container, selections)
|
||||
import_custom_attribute_data(container, selections)
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
||||
|
|
@ -47,7 +49,8 @@ class FbxLoader(load.LoaderPlugin):
|
|||
inst_name, _ = os.path.split(container["instance_node"])
|
||||
container = rt.getNodeByName(inst_name)
|
||||
rt.Select(node.Children)
|
||||
update_Openpype_Data(container, rt.GetCurrentSelection())
|
||||
update_custom_attribute_data(
|
||||
container, rt.GetCurrentSelection())
|
||||
rt.FBXImporterSetParam("Animation", True)
|
||||
rt.FBXImporterSetParam("Camera", True)
|
||||
rt.FBXImporterSetParam("Mode", rt.Name("merge"))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
from openpype.pipeline import load, get_representation_path
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
|
|
@ -47,7 +49,8 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
self.log.error("Something failed when loading.")
|
||||
|
||||
abc_container = abc_containers.pop()
|
||||
import_OpenpypeData(abc_container, abc_container.Children)
|
||||
import_custom_attribute_data(
|
||||
abc_container, abc_container.Children)
|
||||
return containerise(
|
||||
name, [abc_container], context, loader=self.__class__.__name__
|
||||
)
|
||||
|
|
@ -64,7 +67,7 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
rt.Select(node)
|
||||
for alembic in rt.Selection:
|
||||
abc = rt.GetNodeByName(alembic.name)
|
||||
update_Openpype_Data(abc, abc.Children)
|
||||
update_custom_attribute_data(abc, abc.Children)
|
||||
rt.Select(abc.Children)
|
||||
for abc_con in rt.Selection:
|
||||
container = rt.GetNodeByName(abc_con.name)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from openpype.pipeline import load, get_representation_path
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise, import_custom_attribute_data, update_custom_attribute_data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
|
|
@ -32,7 +32,7 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
container.name = name
|
||||
|
||||
selections = rt.GetCurrentSelection()
|
||||
import_OpenpypeData(container, selections)
|
||||
import_custom_attribute_data(container, selections)
|
||||
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
|
@ -57,7 +57,8 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
rt.importFile(path, rt.name("noPrompt"), using=rt.FBXIMP)
|
||||
|
||||
container = rt.getNodeByName(inst_name)
|
||||
update_Openpype_Data(container, rt.GetCurrentSelection())
|
||||
update_custom_attribute_data(
|
||||
container, rt.GetCurrentSelection())
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ import os
|
|||
|
||||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import containerise, import_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
||||
|
|
@ -26,7 +30,7 @@ class ObjLoader(load.LoaderPlugin):
|
|||
container = rt.Container()
|
||||
container.name = name
|
||||
selections = rt.GetCurrentSelection()
|
||||
import_OpenpypeData(container, selections)
|
||||
import_custom_attribute_data(container, selections)
|
||||
# get current selection
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
|
@ -53,7 +57,7 @@ class ObjLoader(load.LoaderPlugin):
|
|||
selections = rt.GetCurrentSelection()
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
import_OpenpypeData(container, selections)
|
||||
update_custom_attribute_data(container, selections)
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import os
|
|||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
|
@ -33,7 +35,7 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
rt.USDImporter.importFile(filepath,
|
||||
importOptions=import_options)
|
||||
asset = rt.GetNodeByName(name)
|
||||
import_OpenpypeData(asset, asset.Children)
|
||||
import_custom_attribute_data(asset, asset.Children)
|
||||
|
||||
return containerise(
|
||||
name, [asset], context, loader=self.__class__.__name__)
|
||||
|
|
@ -62,7 +64,7 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
|
||||
asset = rt.GetNodeByName(instance_name)
|
||||
asset.Parent = node
|
||||
update_Openpype_Data(asset, asset.Children)
|
||||
update_custom_attribute_data(asset, asset.Children)
|
||||
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import os
|
|||
from openpype.pipeline import load, get_representation_path
|
||||
from openpype.hosts.max.api import lib, maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -51,7 +53,8 @@ class AbcLoader(load.LoaderPlugin):
|
|||
|
||||
abc_container = abc_containers.pop()
|
||||
selections = rt.GetCurrentSelection()
|
||||
import_OpenpypeData(abc_container, abc_container.Children)
|
||||
import_custom_attribute_data(
|
||||
abc_container, abc_container.Children)
|
||||
for abc in selections:
|
||||
for cam_shape in abc.Children:
|
||||
cam_shape.playbackType = 2
|
||||
|
|
@ -77,7 +80,7 @@ class AbcLoader(load.LoaderPlugin):
|
|||
|
||||
for alembic in rt.Selection:
|
||||
abc = rt.GetNodeByName(alembic.name)
|
||||
update_Openpype_Data(abc, abc.Children)
|
||||
update_custom_attribute_data(abc, abc.Children)
|
||||
rt.Select(abc.Children)
|
||||
for abc_con in rt.Selection:
|
||||
container = rt.GetNodeByName(abc_con.name)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import os
|
|||
|
||||
from openpype.hosts.max.api import lib, maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
|
@ -27,7 +29,7 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
prt_container = rt.container()
|
||||
prt_container.name = name
|
||||
obj.Parent = prt_container
|
||||
import_OpenpypeData(prt_container, [obj])
|
||||
import_custom_attribute_data(prt_container, [obj])
|
||||
|
||||
return containerise(
|
||||
name, [prt_container], context, loader=self.__class__.__name__)
|
||||
|
|
@ -43,7 +45,7 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
for prt in rt.Selection:
|
||||
prt_object = rt.GetNodeByName(prt.name)
|
||||
prt_object.filename = path
|
||||
update_Openpype_Data(node, node.Children)
|
||||
update_custom_attribute_data(node, node.Children)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ from openpype.pipeline import (
|
|||
get_representation_path
|
||||
)
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
containerise,
|
||||
import_custom_attribute_data,
|
||||
update_custom_attribute_data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
container = rt.container()
|
||||
container.name = name
|
||||
rs_proxy.Parent = container
|
||||
import_OpenpypeData(container, [rs_proxy])
|
||||
import_custom_attribute_data(container, [rs_proxy])
|
||||
asset = rt.getNodeByName(name)
|
||||
|
||||
return containerise(
|
||||
|
|
@ -51,7 +53,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
for proxy in children_node.Children:
|
||||
proxy.file = path
|
||||
|
||||
update_Openpype_Data(node, node.Children)
|
||||
update_custom_attribute_data(node, node.Children)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue