clean up the load OpenpypeData code

This commit is contained in:
Kayla Man 2023-08-14 18:06:23 +08:00
parent 628c9e6cc4
commit cb086d113e
9 changed files with 22 additions and 48 deletions

View file

@ -33,7 +33,7 @@ class FbxLoader(load.LoaderPlugin):
container = rt.Container()
container.name = f"{name}"
selections = rt.GetCurrentSelection()
load_OpenpypeData(container, selections)
load_OpenpypeData()
for selection in selections:
selection.Parent = container
@ -52,7 +52,7 @@ class FbxLoader(load.LoaderPlugin):
rt.FBXImporterSetParam("Preserveinstances", True)
rt.ImportFile(
path, rt.name("noPrompt"), using=rt.FBXIMP)
load_OpenpypeData(node, node.Children)
load_OpenpypeData()
with maintained_selection():
rt.Select(node)

View file

@ -45,10 +45,7 @@ class ModelAbcLoader(load.LoaderPlugin):
self.log.error("Something failed when loading.")
abc_container = abc_containers.pop()
selections = rt.GetCurrentSelection()
abc_selections = [abc for abc in selections
if abc.name != "Alembic"]
load_OpenpypeData(abc_container, abc_selections)
load_OpenpypeData()
return containerise(
name, [abc_container], context, loader=self.__class__.__name__
)
@ -61,7 +58,6 @@ class ModelAbcLoader(load.LoaderPlugin):
rt.Select(node.Children)
nodes_list = []
abc_object = None
with maintained_selection():
rt.Select(node)
@ -77,9 +73,8 @@ class ModelAbcLoader(load.LoaderPlugin):
alembic_obj = rt.GetNodeByName(abc_obj.name)
alembic_obj.source = path
nodes_list.append(alembic_obj)
abc_selections = [abc for abc in nodes_list
if abc.name != "Alembic"]
load_OpenpypeData(abc_object, abc_selections)
load_OpenpypeData()
lib.imprint(
container["instance_node"],

View file

@ -29,7 +29,7 @@ class FbxModelLoader(load.LoaderPlugin):
container.name = name
selections = rt.GetCurrentSelection()
load_OpenpypeData(container, selections)
load_OpenpypeData()
for selection in selections:
selection.Parent = container
@ -50,7 +50,7 @@ class FbxModelLoader(load.LoaderPlugin):
rt.FBXImporterSetParam("UpAxis", "Y")
rt.FBXImporterSetParam("Preserveinstances", True)
rt.importFile(path, rt.name("noPrompt"), using=rt.FBXIMP)
load_OpenpypeData(container, node.Children)
load_OpenpypeData()
with maintained_selection():
rt.Select(node)

View file

@ -26,7 +26,7 @@ class ObjLoader(load.LoaderPlugin):
container = rt.Container()
container.name = name
selections = rt.GetCurrentSelection()
load_OpenpypeData(container, selections)
load_OpenpypeData()
# 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(container, container.Children)
load_OpenpypeData()
with maintained_selection():
rt.Select(node)

View file

@ -30,10 +30,8 @@ class ModelUSDLoader(load.LoaderPlugin):
rt.LogLevel = rt.Name("info")
rt.USDImporter.importFile(filepath,
importOptions=import_options)
selections = rt.GetCurrentSelection()
asset = rt.GetNodeByName(name)
mesh_selections = [r for r in selections if r != asset]
load_OpenpypeData(asset, mesh_selections)
load_OpenpypeData()
return containerise(
name, [asset], context, loader=self.__class__.__name__)
@ -62,7 +60,7 @@ class ModelUSDLoader(load.LoaderPlugin):
asset = rt.GetNodeByName(instance_name)
asset.Parent = node
load_OpenpypeData(asset, asset.Children)
load_OpenpypeData()
with maintained_selection():
rt.Select(node)

View file

@ -49,9 +49,7 @@ class AbcLoader(load.LoaderPlugin):
abc_container = abc_containers.pop()
selections = rt.GetCurrentSelection()
abc_selections = [abc for abc in selections
if abc.name != "Alembic"]
load_OpenpypeData(abc_container, abc_selections)
load_OpenpypeData()
for abc in selections:
for cam_shape in abc.Children:
cam_shape.playbackType = 2
@ -72,7 +70,6 @@ class AbcLoader(load.LoaderPlugin):
{"representation": str(representation["_id"])},
)
nodes_list = []
abc_object = None
with maintained_selection():
rt.Select(node.Children)
@ -88,8 +85,7 @@ class AbcLoader(load.LoaderPlugin):
alembic_obj = rt.GetNodeByName(abc_obj.name)
alembic_obj.source = path
nodes_list.append(alembic_obj)
abc_selections = [abc for abc in nodes_list if abc.name != "Alembic"]
load_OpenpypeData(abc_object, abc_selections)
load_OpenpypeData()
def switch(self, container, representation):
self.update(container, representation)

View file

@ -25,7 +25,7 @@ class PointCloudLoader(load.LoaderPlugin):
prt_container = rt.container()
prt_container.name = name
obj.Parent = prt_container
load_OpenpypeData(prt_container, [obj])
load_OpenpypeData()
return containerise(
name, [prt_container], context, loader=self.__class__.__name__)
@ -41,7 +41,7 @@ class PointCloudLoader(load.LoaderPlugin):
for prt in rt.Selection:
prt_object = rt.GetNodeByName(prt.name)
prt_object.filename = path
load_OpenpypeData(node, node.Children)
load_OpenpypeData()
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
})

View file

@ -33,7 +33,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
container = rt.container()
container.name = name
rs_proxy.Parent = container
load_OpenpypeData(container, [rs_proxy])
load_OpenpypeData()
asset = rt.getNodeByName(name)
return containerise(
@ -49,7 +49,7 @@ class RedshiftProxyLoader(load.LoaderPlugin):
for proxy in children_node.Children:
proxy.file = path
load_OpenpypeData(node, node.Children)
load_OpenpypeData()
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
})