mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
reload the modifiers to the container with OP Data
This commit is contained in:
parent
fdad1a48b0
commit
e666ff641b
9 changed files with 78 additions and 32 deletions
|
|
@ -180,3 +180,30 @@ def load_OpenpypeData():
|
|||
attribute: re-loading the custom OP attributes set in Maxscript
|
||||
"""
|
||||
return rt.Execute(MS_CUSTOM_ATTRIB)
|
||||
|
||||
|
||||
def import_OpenpypeData(container, selections):
|
||||
attrs = load_OpenpypeData()
|
||||
modifier = rt.EmptyModifier()
|
||||
rt.addModifier(container, modifier)
|
||||
container.modifiers[0].name = "OP Data"
|
||||
rt.custAttributes.add(container.modifiers[0], attrs)
|
||||
node_list = []
|
||||
sel_list = []
|
||||
for i in selections:
|
||||
node_ref = rt.NodeTransformMonitor(node=i)
|
||||
node_list.append(node_ref)
|
||||
sel_list.append(str(i))
|
||||
# Setting the property
|
||||
rt.setProperty(
|
||||
container.modifiers[0].openPypeData,
|
||||
"all_handles", node_list)
|
||||
rt.setProperty(
|
||||
container.modifiers[0].openPypeData,
|
||||
"sel_list", sel_list)
|
||||
|
||||
|
||||
def update_Openpype_Data(container, selections):
|
||||
if container.modifiers[0].name == "OP Data":
|
||||
rt.deleteModifier(container, container.modifiers[0])
|
||||
import_OpenpypeData(container, selections)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
|
||||
from openpype.hosts.max.api import lib, maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import containerise, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
||||
|
|
@ -16,24 +18,21 @@ class FbxLoader(load.LoaderPlugin):
|
|||
|
||||
def load(self, context, name=None, namespace=None, data=None):
|
||||
from pymxs import runtime as rt
|
||||
|
||||
filepath = self.filepath_from_context(context)
|
||||
filepath = os.path.normpath(filepath)
|
||||
rt.FBXImporterSetParam("Animation", True)
|
||||
rt.FBXImporterSetParam("Camera", True)
|
||||
rt.FBXImporterSetParam("AxisConversionMethod", True)
|
||||
rt.FBXImporterSetParam("Mode", rt.Name("create"))
|
||||
rt.FBXImporterSetParam("Preserveinstances", True)
|
||||
rt.ImportFile(
|
||||
filepath,
|
||||
rt.name("noPrompt"),
|
||||
using=rt.FBXIMP)
|
||||
|
||||
container = rt.GetNodeByName(f"{name}")
|
||||
if not container:
|
||||
container = rt.Container()
|
||||
container.name = f"{name}"
|
||||
container = rt.container(name=name)
|
||||
selections = rt.GetCurrentSelection()
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(container, selections)
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
||||
|
|
@ -45,14 +44,17 @@ class FbxLoader(load.LoaderPlugin):
|
|||
|
||||
path = get_representation_path(representation)
|
||||
node = rt.GetNodeByName(container["instance_node"])
|
||||
inst_name, _ = os.path.split(container["instance_node"])
|
||||
container = rt.getNodeByName(inst_name)
|
||||
rt.Select(node.Children)
|
||||
update_Openpype_Data(container, rt.GetCurrentSelection())
|
||||
rt.FBXImporterSetParam("Animation", True)
|
||||
rt.FBXImporterSetParam("Camera", True)
|
||||
rt.FBXImporterSetParam("Mode", rt.Name("merge"))
|
||||
rt.FBXImporterSetParam("AxisConversionMethod", True)
|
||||
rt.FBXImporterSetParam("Preserveinstances", True)
|
||||
rt.ImportFile(
|
||||
path, rt.name("noPrompt"), using=rt.FBXIMP)
|
||||
load_OpenpypeData()
|
||||
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
from openpype.pipeline import load, get_representation_path
|
||||
from openpype.hosts.max.api.pipeline import containerise, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
|
||||
|
|
@ -30,7 +32,7 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
rt.AlembicImport.CustomAttributes = True
|
||||
rt.AlembicImport.UVs = True
|
||||
rt.AlembicImport.VertexColors = True
|
||||
rt.importFile(file_path, rt.name("noPrompt"))
|
||||
rt.importFile(file_path, rt.name("noPrompt"), using=rt.AlembicImport)
|
||||
|
||||
abc_after = {
|
||||
c
|
||||
|
|
@ -45,7 +47,7 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
self.log.error("Something failed when loading.")
|
||||
|
||||
abc_container = abc_containers.pop()
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(abc_container, abc_container.Children)
|
||||
return containerise(
|
||||
name, [abc_container], context, loader=self.__class__.__name__
|
||||
)
|
||||
|
|
@ -62,6 +64,7 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
rt.Select(node)
|
||||
for alembic in rt.Selection:
|
||||
abc = rt.GetNodeByName(alembic.name)
|
||||
import_OpenpypeData(abc, abc.Children)
|
||||
rt.Select(abc.Children)
|
||||
for abc_con in rt.Selection:
|
||||
container = rt.GetNodeByName(abc_con.name)
|
||||
|
|
@ -72,8 +75,6 @@ class ModelAbcLoader(load.LoaderPlugin):
|
|||
alembic_obj.source = path
|
||||
nodes_list.append(alembic_obj)
|
||||
|
||||
load_OpenpypeData()
|
||||
|
||||
lib.imprint(
|
||||
container["instance_node"],
|
||||
{"representation": str(representation["_id"])},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
from openpype.pipeline import load, get_representation_path
|
||||
from openpype.hosts.max.api.pipeline import containerise, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
from openpype.hosts.max.api.lib import maintained_selection
|
||||
|
||||
|
|
@ -20,6 +22,7 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
filepath = os.path.normpath(self.filepath_from_context(context))
|
||||
rt.FBXImporterSetParam("Animation", False)
|
||||
rt.FBXImporterSetParam("Cameras", False)
|
||||
rt.FBXImporterSetParam("Mode", rt.Name("create"))
|
||||
rt.FBXImporterSetParam("Preserveinstances", True)
|
||||
rt.importFile(filepath, rt.name("noPrompt"), using=rt.FBXIMP)
|
||||
|
||||
|
|
@ -29,7 +32,7 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
container.name = name
|
||||
|
||||
selections = rt.GetCurrentSelection()
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(container, selections)
|
||||
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
|
@ -42,15 +45,19 @@ class FbxModelLoader(load.LoaderPlugin):
|
|||
from pymxs import runtime as rt
|
||||
path = get_representation_path(representation)
|
||||
node = rt.getNodeByName(container["instance_node"])
|
||||
inst_name, _ = os.path.splitext(container["instance_node"])
|
||||
rt.select(node.Children)
|
||||
|
||||
rt.FBXImporterSetParam("Animation", False)
|
||||
rt.FBXImporterSetParam("Cameras", False)
|
||||
rt.FBXImporterSetParam("Mode", rt.Name("merge"))
|
||||
rt.FBXImporterSetParam("AxisConversionMethod", True)
|
||||
rt.FBXImporterSetParam("UpAxis", "Y")
|
||||
rt.FBXImporterSetParam("Preserveinstances", True)
|
||||
rt.importFile(path, rt.name("noPrompt"), using=rt.FBXIMP)
|
||||
load_OpenpypeData()
|
||||
|
||||
container = rt.getNodeByName(inst_name)
|
||||
update_Openpype_Data(container, rt.GetCurrentSelection())
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ 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, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import containerise, import_OpenpypeData
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class ObjLoader(load.LoaderPlugin):
|
|||
container = rt.Container()
|
||||
container.name = name
|
||||
selections = rt.GetCurrentSelection()
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(container, selections)
|
||||
# get current selection
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
|
|
@ -53,7 +53,7 @@ class ObjLoader(load.LoaderPlugin):
|
|||
selections = rt.GetCurrentSelection()
|
||||
for selection in selections:
|
||||
selection.Parent = container
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(container, selections)
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,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, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
||||
|
|
@ -31,7 +33,7 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
rt.USDImporter.importFile(filepath,
|
||||
importOptions=import_options)
|
||||
asset = rt.GetNodeByName(name)
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(asset, asset.Children)
|
||||
|
||||
return containerise(
|
||||
name, [asset], context, loader=self.__class__.__name__)
|
||||
|
|
@ -60,7 +62,7 @@ class ModelUSDLoader(load.LoaderPlugin):
|
|||
|
||||
asset = rt.GetNodeByName(instance_name)
|
||||
asset.Parent = node
|
||||
load_OpenpypeData()
|
||||
update_Openpype_Data(asset, asset.Children)
|
||||
|
||||
with maintained_selection():
|
||||
rt.Select(node)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ Because of limited api, alembics can be only loaded, but not easily updated.
|
|||
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, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
|
||||
|
||||
class AbcLoader(load.LoaderPlugin):
|
||||
|
|
@ -33,7 +35,7 @@ class AbcLoader(load.LoaderPlugin):
|
|||
}
|
||||
|
||||
rt.AlembicImport.ImportToRoot = False
|
||||
rt.importFile(file_path, rt.name("noPrompt"))
|
||||
rt.importFile(file_path, rt.name("noPrompt"), using=rt.AlembicImport)
|
||||
|
||||
abc_after = {
|
||||
c
|
||||
|
|
@ -49,7 +51,7 @@ class AbcLoader(load.LoaderPlugin):
|
|||
|
||||
abc_container = abc_containers.pop()
|
||||
selections = rt.GetCurrentSelection()
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(abc_container, abc_container.Children)
|
||||
for abc in selections:
|
||||
for cam_shape in abc.Children:
|
||||
cam_shape.playbackType = 2
|
||||
|
|
@ -75,6 +77,7 @@ class AbcLoader(load.LoaderPlugin):
|
|||
|
||||
for alembic in rt.Selection:
|
||||
abc = rt.GetNodeByName(alembic.name)
|
||||
update_Openpype_Data(abc, abc.Children)
|
||||
rt.Select(abc.Children)
|
||||
for abc_con in rt.Selection:
|
||||
container = rt.GetNodeByName(abc_con.name)
|
||||
|
|
@ -84,7 +87,7 @@ class AbcLoader(load.LoaderPlugin):
|
|||
alembic_obj = rt.GetNodeByName(abc_obj.name)
|
||||
alembic_obj.source = path
|
||||
nodes_list.append(alembic_obj)
|
||||
load_OpenpypeData()
|
||||
|
||||
|
||||
def switch(self, container, representation):
|
||||
self.update(container, representation)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
|
||||
from openpype.hosts.max.api import lib, maintained_selection
|
||||
from openpype.hosts.max.api.pipeline import containerise, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.pipeline import get_representation_path, load
|
||||
|
||||
|
||||
|
|
@ -25,7 +27,7 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
prt_container = rt.container()
|
||||
prt_container.name = name
|
||||
obj.Parent = prt_container
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(prt_container, [obj])
|
||||
|
||||
return containerise(
|
||||
name, [prt_container], context, loader=self.__class__.__name__)
|
||||
|
|
@ -41,7 +43,7 @@ class PointCloudLoader(load.LoaderPlugin):
|
|||
for prt in rt.Selection:
|
||||
prt_object = rt.GetNodeByName(prt.name)
|
||||
prt_object.filename = path
|
||||
load_OpenpypeData()
|
||||
update_Openpype_Data(node, node.Children)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ from openpype.pipeline import (
|
|||
load,
|
||||
get_representation_path
|
||||
)
|
||||
from openpype.hosts.max.api.pipeline import containerise, load_OpenpypeData
|
||||
from openpype.hosts.max.api.pipeline import (
|
||||
containerise, import_OpenpypeData, update_Openpype_Data
|
||||
)
|
||||
from openpype.hosts.max.api import lib
|
||||
|
||||
|
||||
|
|
@ -33,7 +35,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
container = rt.container()
|
||||
container.name = name
|
||||
rs_proxy.Parent = container
|
||||
load_OpenpypeData()
|
||||
import_OpenpypeData(container, [rs_proxy])
|
||||
asset = rt.getNodeByName(name)
|
||||
|
||||
return containerise(
|
||||
|
|
@ -49,7 +51,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
|
|||
for proxy in children_node.Children:
|
||||
proxy.file = path
|
||||
|
||||
load_OpenpypeData()
|
||||
update_Openpype_Data(node, node.Children)
|
||||
lib.imprint(container["instance_node"], {
|
||||
"representation": str(representation["_id"])
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue