🚨 style changes

This commit is contained in:
Ondrej Samohel 2023-05-23 15:50:07 +02:00
parent bcaa443996
commit 8ac4cb499e
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
19 changed files with 221 additions and 411 deletions

View file

@ -1,16 +1,13 @@
# -*- coding: utf-8 -*-
"""Library of functions useful for 3dsmax pipeline."""
import json
import six
from pymxs import runtime as rt
from typing import Union, Any, Dict
import contextlib
import json
from typing import Any, Dict, Union
import six
from openpype.pipeline.context_tools import (
get_current_project_asset,
get_current_project
)
get_current_project, get_current_project_asset,)
from pymxs import runtime as rt
JSON_PREFIX = "JSON::"
@ -22,7 +19,7 @@ def imprint(node_name: str, data: dict) -> bool:
for k, v in data.items():
if isinstance(v, (dict, list)):
rt.SetUserProp(node, k, f'{JSON_PREFIX}{json.dumps(v)}')
rt.SetUserProp(node, k, f"{JSON_PREFIX}{json.dumps(v)}")
else:
rt.SetUserProp(node, k, v)
@ -171,7 +168,7 @@ def set_scene_resolution(width: int, height: int):
"""
# make sure the render dialog is closed
# for the update of resolution
# Changing the Render Setup dialog settingsshould be done
# Changing the Render Setup dialog settings should be done
# with the actual Render Setup dialog in a closed state.
if rt.renderSceneDialog.isOpen():
rt.renderSceneDialog.close()
@ -179,6 +176,7 @@ def set_scene_resolution(width: int, height: int):
rt.renderWidth = width
rt.renderHeight = height
def reset_scene_resolution():
"""Apply the scene resolution from the project definition
@ -248,7 +246,7 @@ def reset_frame_range(fps: bool = True):
frange_cmd = (
f"animationRange = interval {frame_start_handle} {frame_end_handle}"
)
rt.execute(frange_cmd)
rt.Execute(frange_cmd)
set_render_frame_range(frame_start_handle, frame_end_handle)

View file

@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
"""3dsmax specific Avalon/Pyblish plugin definitions."""
from pymxs import runtime as rt
from typing import Union
import six
from abc import ABCMeta
from openpype.pipeline import (
CreatorError,
Creator,
CreatedInstance
)
import six
from pymxs import runtime as rt
from openpype.lib import BoolDef
from .lib import imprint, read, lsattr
from openpype.pipeline import CreatedInstance, Creator, CreatorError
from .lib import imprint, lsattr, read
MS_CUSTOM_ATTRIB = """attributes "openPypeData"
(
@ -100,17 +98,18 @@ class MaxCreatorBase(object):
@staticmethod
def cache_subsets(shared_data):
if shared_data.get("max_cached_subsets") is None:
shared_data["max_cached_subsets"] = {}
cached_instances = lsattr("id", "pyblish.avalon.instance")
for i in cached_instances:
creator_id = rt.getUserProp(i, "creator_identifier")
if creator_id not in shared_data["max_cached_subsets"]:
shared_data["max_cached_subsets"][creator_id] = [i.name]
else:
shared_data[
"max_cached_subsets"][creator_id].append(
i.name) # noqa
if shared_data.get("max_cached_subsets"):
return shared_data
shared_data["max_cached_subsets"] = {}
cached_instances = lsattr("id", "pyblish.avalon.instance")
for i in cached_instances:
creator_id = rt.GetUserProp(i, "creator_identifier")
if creator_id not in shared_data["max_cached_subsets"]:
shared_data["max_cached_subsets"][creator_id] = [i.name]
else:
shared_data[
"max_cached_subsets"][creator_id].append(i.name)
return shared_data
@staticmethod
@ -127,9 +126,9 @@ class MaxCreatorBase(object):
instance
"""
if isinstance(node, str):
node = rt.container(name=node)
node = rt.Container(name=node)
attrs = rt.execute(MS_CUSTOM_ATTRIB)
attrs = rt.Execute(MS_CUSTOM_ATTRIB)
rt.custAttributes.add(node.baseObject, attrs)
return node
@ -141,7 +140,7 @@ class MaxCreator(Creator, MaxCreatorBase):
def create(self, subset_name, instance_data, pre_create_data):
if pre_create_data.get("use_selection"):
self.selected_nodes = rt.getCurrentSelection()
self.selected_nodes = rt.GetCurrentSelection()
instance_node = self.create_instance_node(subset_name)
instance_data["instance_node"] = instance_node.name
@ -196,9 +195,12 @@ class MaxCreator(Creator, MaxCreatorBase):
"""
for instance in instances:
if instance_node := rt.GetNodeByName(instance.data.get("instance_node")): # noqa
if instance_node := rt.GetNodeByName(
instance.data.get("instance_node")):
rt.Select(instance_node)
rt.execute(f'for o in selection do for c in o.children do c.parent = undefined') # noqa
rt.Execute(
("for o in selection do "
"for c in o.children do c.parent = undefined"))
rt.Delete(instance_node)
self._remove_instance_from_context(instance)

View file

@ -18,10 +18,7 @@ class CreateRender(plugin.MaxCreator):
instance_data,
pre_create_data)
container_name = instance.data.get("instance_node")
# TODO: Disable "Add to Containers?" Panel
# parent the selected cameras into the container
sel_obj = self.selected_nodes
if sel_obj:
if sel_obj := self.selected_nodes:
# set viewport camera for rendering(mandatory for deadline)
RenderSettings(self.project_settings).set_render_camera(sel_obj)
# set output paths for rendering(mandatory for deadline)

View file

@ -1,14 +1,12 @@
import os
from openpype.pipeline import (
load,
get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib, maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class FbxLoader(load.LoaderPlugin):
"""Fbx Loader"""
"""Fbx Loader."""
families = ["camera"]
representations = ["fbx"]
@ -24,17 +22,17 @@ class FbxLoader(load.LoaderPlugin):
rt.FBXImporterSetParam("Camera", True)
rt.FBXImporterSetParam("AxisConversionMethod", True)
rt.FBXImporterSetParam("Preserveinstances", True)
rt.importFile(
rt.ImportFile(
filepath,
rt.name("noPrompt"),
using=rt.FBXIMP)
container = rt.getNodeByName(f"{name}")
container = rt.GetNodeByName(f"{name}")
if not container:
container = rt.container()
container = rt.Container()
container.name = f"{name}"
for selection in rt.getCurrentSelection():
for selection in rt.GetCurrentSelection():
selection.Parent = container
return containerise(
@ -44,8 +42,8 @@ class FbxLoader(load.LoaderPlugin):
from pymxs import runtime as rt
path = get_representation_path(representation)
node = rt.getNodeByName(container["instance_node"])
rt.select(node.Children)
node = rt.GetNodeByName(container["instance_node"])
rt.Select(node.Children)
fbx_reimport_cmd = (
f"""
@ -57,10 +55,10 @@ FbxExporterSetParam "Preserveinstances" true
importFile @"{path}" #noPrompt using:FBXIMP
""")
rt.execute(fbx_reimport_cmd)
rt.Execute(fbx_reimport_cmd)
with maintained_selection():
rt.select(node)
rt.Select(node)
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
@ -72,5 +70,5 @@ importFile @"{path}" #noPrompt using:FBXIMP
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -1,13 +1,12 @@
import os
from openpype.pipeline import (
load, get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class MaxSceneLoader(load.LoaderPlugin):
"""Max Scene Loader"""
"""Max Scene Loader."""
families = ["camera",
"maxScene",
@ -24,16 +23,12 @@ class MaxSceneLoader(load.LoaderPlugin):
# import the max scene by using "merge file"
path = path.replace('\\', '/')
merge_before = {
c for c in rt.rootNode.Children
}
rt.mergeMaxFile(path)
merge_before = set(rt.RootNode.Children)
rt.MergeMaxFile(path)
merge_after = {
c for c in rt.rootNode.Children
}
merge_after = set(rt.RootNode.Children)
max_objects = merge_after.difference(merge_before)
max_container = rt.container(name=f"{name}")
max_container = rt.Container(name=f"{name}")
for max_object in max_objects:
max_object.Parent = max_container
@ -46,18 +41,14 @@ class MaxSceneLoader(load.LoaderPlugin):
path = get_representation_path(representation)
node_name = container["instance_node"]
instance_name, _ = node_name.split("_")
merge_before = {
c for c in rt.rootNode.Children
}
rt.mergeMaxFile(path,
merge_before = set(rt.RootNode.Children)
rt.MergeMaxFile(path,
rt.Name("noRedraw"),
rt.Name("deleteOldDups"),
rt.Name("useSceneMtlDups"))
merge_after = {
c for c in rt.rootNode.Children
}
merge_after = set(rt.EootNode.Children)
max_objects = merge_after.difference(merge_before)
container_node = rt.getNodeByName(instance_name)
container_node = rt.GetNodeByName(instance_name)
for max_object in max_objects:
max_object.Parent = container_node
@ -71,5 +62,5 @@ class MaxSceneLoader(load.LoaderPlugin):
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -1,11 +1,10 @@
import os
from openpype.pipeline import (
load, get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib
from openpype.hosts.max.api.lib import maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class ModelAbcLoader(load.LoaderPlugin):
@ -24,8 +23,8 @@ class ModelAbcLoader(load.LoaderPlugin):
file_path = os.path.normpath(self.fname)
abc_before = {
c for c in rt.rootNode.Children
if rt.classOf(c) == rt.AlembicContainer
c for c in rt.RootNode.Children
if rt.ClassOf(c) == rt.AlembicContainer
}
abc_import_cmd = (f"""
@ -38,11 +37,11 @@ importFile @"{file_path}" #noPrompt
""")
self.log.debug(f"Executing command: {abc_import_cmd}")
rt.execute(abc_import_cmd)
rt.Execute(abc_import_cmd)
abc_after = {
c for c in rt.rootNode.Children
if rt.classOf(c) == rt.AlembicContainer
c for c in rt.RootNode.Children
if rt.ClassOf(c) == rt.AlembicContainer
}
# This should yield new AlembicContainer node
@ -59,22 +58,22 @@ importFile @"{file_path}" #noPrompt
def update(self, container, representation):
from pymxs import runtime as rt
path = get_representation_path(representation)
node = rt.getNodeByName(container["instance_node"])
rt.select(node.Children)
node = rt.GetNodeByName(container["instance_node"])
rt.Select(node.Children)
for alembic in rt.selection:
abc = rt.getNodeByName(alembic.name)
rt.select(abc.Children)
for abc_con in rt.selection:
container = rt.getNodeByName(abc_con.name)
for alembic in rt.Selection:
abc = rt.GetNodeByName(alembic.name)
rt.Select(abc.Children)
for abc_con in rt.Selection:
container = rt.GetNodeByName(abc_con.name)
container.source = path
rt.select(container.Children)
for abc_obj in rt.selection:
alembic_obj = rt.getNodeByName(abc_obj.name)
rt.Select(container.Children)
for abc_obj in rt.Selection:
alembic_obj = rt.GetNodeByName(abc_obj.name)
alembic_obj.source = path
with maintained_selection():
rt.select(node)
rt.Select(node)
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
@ -86,8 +85,8 @@ importFile @"{file_path}" #noPrompt
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)
@staticmethod
def get_container_children(parent, type_name):
@ -102,7 +101,7 @@ importFile @"{file_path}" #noPrompt
filtered = []
for child in list_children(parent):
class_type = str(rt.classOf(child.baseObject))
class_type = str(rt.ClassOf(child.baseObject))
if class_type == type_name:
filtered.append(child)

View file

@ -1,15 +1,13 @@
import os
from openpype.pipeline import (
load,
get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib
from openpype.hosts.max.api.lib import maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class FbxModelLoader(load.LoaderPlugin):
"""Fbx Model Loader"""
"""Fbx Model Loader."""
families = ["model"]
representations = ["fbx"]
@ -24,17 +22,17 @@ class FbxModelLoader(load.LoaderPlugin):
rt.FBXImporterSetParam("Animation", False)
rt.FBXImporterSetParam("Cameras", False)
rt.FBXImporterSetParam("Preserveinstances", True)
rt.importFile(
rt.ImportFile(
filepath,
rt.name("noPrompt"),
rt.Name("noPrompt"),
using=rt.FBXIMP)
container = rt.getNodeByName(f"{name}")
container = rt.GetNodeByName(name)
if not container:
container = rt.container()
container.name = f"{name}"
container = rt.Container()
container.name = name
for selection in rt.getCurrentSelection():
for selection in rt.GetCurrentSelection():
selection.Parent = container
return containerise(
@ -44,8 +42,8 @@ class FbxModelLoader(load.LoaderPlugin):
from pymxs import runtime as rt
path = get_representation_path(representation)
node = rt.getNodeByName(container["instance_node"])
rt.select(node.Children)
node = rt.GetNodeByName(container["instance_node"])
rt.Select(node.Children)
fbx_reimport_cmd = (
f"""
FBXImporterSetParam "Animation" false
@ -56,10 +54,10 @@ FbxExporterSetParam "Preserveinstances" true
importFile @"{path}" #noPrompt using:FBXIMP
""")
rt.execute(fbx_reimport_cmd)
rt.Execute(fbx_reimport_cmd)
with maintained_selection():
rt.select(node)
rt.Select(node)
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
@ -71,5 +69,5 @@ importFile @"{path}" #noPrompt using:FBXIMP
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -1,15 +1,13 @@
import os
from openpype.pipeline import (
load,
get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib
from openpype.hosts.max.api.lib import maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class ObjLoader(load.LoaderPlugin):
"""Obj Loader"""
"""Obj Loader."""
families = ["model"]
representations = ["obj"]
@ -21,18 +19,18 @@ class ObjLoader(load.LoaderPlugin):
from pymxs import runtime as rt
filepath = os.path.normpath(self.fname)
self.log.debug(f"Executing command to import..")
self.log.debug("Executing command to import..")
rt.execute(f'importFile @"{filepath}" #noPrompt using:ObjImp')
rt.Execute(f'importFile @"{filepath}" #noPrompt using:ObjImp')
# create "missing" container for obj import
container = rt.container()
container.name = f"{name}"
container = rt.Container()
container.name = name
# get current selection
for selection in rt.getCurrentSelection():
for selection in rt.GetCurrentSelection():
selection.Parent = container
asset = rt.getNodeByName(f"{name}")
asset = rt.GetNodeByName(name)
return containerise(
name, [asset], context, loader=self.__class__.__name__)
@ -42,20 +40,20 @@ class ObjLoader(load.LoaderPlugin):
path = get_representation_path(representation)
node_name = container["instance_node"]
node = rt.getNodeByName(node_name)
node = rt.GetNodeByName(node_name)
instance_name, _ = node_name.split("_")
container = rt.getNodeByName(instance_name)
for n in container.Children:
rt.delete(n)
container = rt.GetNodeByName(instance_name)
for child in container.Children:
rt.Delete(child)
rt.execute(f'importFile @"{path}" #noPrompt using:ObjImp')
rt.Execute(f'importFile @"{path}" #noPrompt using:ObjImp')
# get current selection
for selection in rt.getCurrentSelection():
for selection in rt.GetCurrentSelection():
selection.Parent = container
with maintained_selection():
rt.select(node)
rt.Select(node)
lib.imprint(node_name, {
"representation": str(representation["_id"])
@ -67,5 +65,5 @@ class ObjLoader(load.LoaderPlugin):
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -1,10 +1,9 @@
import os
from openpype.pipeline import (
load, get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib
from openpype.hosts.max.api.lib import maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class ModelUSDLoader(load.LoaderPlugin):
@ -19,6 +18,7 @@ class ModelUSDLoader(load.LoaderPlugin):
def load(self, context, name=None, namespace=None, data=None):
from pymxs import runtime as rt
# asset_filepath
filepath = os.path.normpath(self.fname)
import_options = rt.USDImporter.CreateOptions()
@ -27,11 +27,11 @@ class ModelUSDLoader(load.LoaderPlugin):
log_filepath = filepath.replace(ext, "txt")
rt.LogPath = log_filepath
rt.LogLevel = rt.name('info')
rt.LogLevel = rt.Name("info")
rt.USDImporter.importFile(filepath,
importOptions=import_options)
asset = rt.getNodeByName(f"{name}")
asset = rt.GetNodeByName(name)
return containerise(
name, [asset], context, loader=self.__class__.__name__)
@ -41,11 +41,11 @@ class ModelUSDLoader(load.LoaderPlugin):
path = get_representation_path(representation)
node_name = container["instance_node"]
node = rt.getNodeByName(node_name)
node = rt.GetNodeByName(node_name)
for n in node.Children:
for r in n.Children:
rt.delete(r)
rt.delete(n)
rt.Delete(r)
rt.Delete(n)
instance_name, _ = node_name.split("_")
import_options = rt.USDImporter.CreateOptions()
@ -54,15 +54,15 @@ class ModelUSDLoader(load.LoaderPlugin):
log_filepath = path.replace(ext, "txt")
rt.LogPath = log_filepath
rt.LogLevel = rt.name('info')
rt.LogLevel = rt.Name("info")
rt.USDImporter.importFile(path,
importOptions=import_options)
asset = rt.getNodeByName(f"{instance_name}")
asset = rt.GetNodeByName(instance_name)
asset.Parent = node
with maintained_selection():
rt.select(node)
rt.Select(node)
lib.imprint(node_name, {
"representation": str(representation["_id"])
@ -74,5 +74,5 @@ class ModelUSDLoader(load.LoaderPlugin):
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -5,11 +5,10 @@ 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.pipeline import containerise
from openpype.hosts.max.api import lib, maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class AbcLoader(load.LoaderPlugin):
@ -30,29 +29,28 @@ class AbcLoader(load.LoaderPlugin):
file_path = os.path.normpath(self.fname)
abc_before = {
c for c in rt.rootNode.Children
if rt.classOf(c) == rt.AlembicContainer
c for c in rt.RootNode.Children
if rt.ClassOf(c) == rt.AlembicContainer
}
rt.AlembicImport.ImportToRoot = False
rt.AlembicImport.StartFrame = True
rt.AlembicImport.EndFrame = True
rt.importFile(file_path, rt.name("noPrompt"))
rt.ImportFile(file_path, rt.Name("noPrompt"))
abc_after = {
c for c in rt.rootNode.Children
if rt.classOf(c) == rt.AlembicContainer
c for c in rt.RootNode.Children
if rt.ClassOf(c) == rt.AlembicContainer
}
# This should yield new AlembicContainer node
abc_containers = abc_after.difference(abc_before)
if len(abc_containers) != 1:
self.log.error("Something failed when loading.")
abc_container = abc_containers.pop()
for abc in rt.getCurrentSelection():
for abc in rt.GetCurrentSelection():
for cam_shape in abc.Children:
cam_shape.playbackType = 2
@ -63,27 +61,25 @@ class AbcLoader(load.LoaderPlugin):
from pymxs import runtime as rt
path = get_representation_path(representation)
node = rt.getNodeByName(container["instance_node"])
node = rt.GetNodeByName(container["instance_node"])
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
})
rt.select(node.Children)
for alembic in rt.selection:
abc = rt.getNodeByName(alembic.name)
rt.select(abc.Children)
for abc_con in rt.selection:
container = rt.getNodeByName(abc_con.name)
container.source = path
rt.select(container.Children)
for abc_obj in rt.selection:
alembic_obj = rt.getNodeByName(abc_obj.name)
alembic_obj.source = path
with maintained_selection():
rt.select(node)
rt.Select(node.Children)
for alembic in rt.Selection:
abc = rt.GetNodeByName(alembic.name)
rt.Select(abc.Children)
for abc_con in rt.Selection:
container = rt.GetNodeByName(abc_con.name)
container.source = path
rt.Select(container.Children)
for abc_obj in rt.Selection:
alembic_obj = rt.GetNodeByName(abc_obj.name)
alembic_obj.source = path
def switch(self, container, representation):
self.update(container, representation)
@ -91,8 +87,8 @@ class AbcLoader(load.LoaderPlugin):
def remove(self, container):
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)
@staticmethod
def get_container_children(parent, type_name):

View file

@ -1,13 +1,12 @@
import os
from openpype.pipeline import (
load, get_representation_path
)
from openpype.hosts.max.api.pipeline import containerise
from openpype.hosts.max.api import lib, maintained_selection
from openpype.hosts.max.api.pipeline import containerise
from openpype.pipeline import get_representation_path, load
class PointCloudLoader(load.LoaderPlugin):
"""Point Cloud Loader"""
"""Point Cloud Loader."""
families = ["pointcloud"]
representations = ["prt"]
@ -23,7 +22,7 @@ class PointCloudLoader(load.LoaderPlugin):
obj = rt.tyCache()
obj.filename = filepath
prt_container = rt.getNodeByName(f"{obj.name}")
prt_container = rt.GetNodeByName(obj.name)
return containerise(
name, [prt_container], context, loader=self.__class__.__name__)
@ -33,18 +32,16 @@ class PointCloudLoader(load.LoaderPlugin):
from pymxs import runtime as rt
path = get_representation_path(representation)
node = rt.getNodeByName(container["instance_node"])
rt.select(node.Children)
for prt in rt.selection:
prt_object = rt.getNodeByName(prt.name)
prt_object.filename = path
node = rt.GetNodeByName(container["instance_node"])
with maintained_selection():
rt.select(node)
rt.Select(node.Children)
for prt in rt.Selection:
prt_object = rt.GetNodeByName(prt.name)
prt_object.filename = path
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
})
lib.imprint(container["instance_node"], {
"representation": str(representation["_id"])
})
def switch(self, container, representation):
self.update(container, representation)
@ -53,5 +50,5 @@ class PointCloudLoader(load.LoaderPlugin):
"""remove the container"""
from pymxs import runtime as rt
node = rt.getNodeByName(container["instance_node"])
rt.delete(node)
node = rt.GetNodeByName(container["instance_node"])
rt.Delete(node)

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
"""Collect instance members"""
"""Collect instance members."""
import pyblish.api
from pymxs import runtime as rt
class CollectMembers(pyblish.api.InstancePlugin):
"""Collect Render for Deadline"""
"""Collect Render for Deadline."""
order = pyblish.api.CollectorOrder + 0.01
label = "Collect Instance Members"
@ -16,5 +16,6 @@ class CollectMembers(pyblish.api.InstancePlugin):
if instance.data.get("instance_node"):
container = rt.GetNodeByName(instance.data["instance_node"])
instance.data["members"] = [
i.node for i in container.openPypeData.all_handles
member.node for member
in container.openPypeData.all_handles
]

View file

@ -1,14 +1,14 @@
import os
import pyblish.api
from openpype.pipeline import publish, OptionalPyblishPluginMixin
from pymxs import runtime as rt
from openpype.hosts.max.api import maintained_selection, get_all_children
from openpype.hosts.max.api import get_all_children, maintained_selection
from openpype.pipeline import OptionalPyblishPluginMixin, publish
class ExtractCameraAlembic(publish.Extractor, OptionalPyblishPluginMixin):
"""
Extract Camera with AlembicExport
"""
"""Extract Camera with AlembicExport."""
order = pyblish.api.ExtractorOrder - 0.1
label = "Extract Alembic Camera"
@ -31,20 +31,20 @@ class ExtractCameraAlembic(publish.Extractor, OptionalPyblishPluginMixin):
path = os.path.join(stagingdir, filename)
# We run the render
self.log.info("Writing alembic '%s' to '%s'" % (filename, stagingdir))
self.log.info(f"Writing alembic '{filename}' to '{stagingdir}'")
rt.AlembicExport.ArchiveType = rt.name("ogawa")
rt.AlembicExport.CoordinateSystem = rt.name("maya")
rt.AlembicExport.ArchiveType = rt.Name("ogawa")
rt.AlembicExport.CoordinateSystem = rt.Name("maya")
rt.AlembicExport.StartFrame = start
rt.AlembicExport.EndFrame = end
rt.AlembicExport.CustomAttributes = True
with maintained_selection():
# select and export
rt.select(get_all_children(rt.getNodeByName(container)))
rt.exportFile(
rt.Select(get_all_children(rt.GetNodeByName(container)))
rt.ExportFile(
path,
rt.name("noPrompt"),
rt.Name("noPrompt"),
selectedOnly=True,
using=rt.AlembicExport,
)
@ -62,4 +62,4 @@ class ExtractCameraAlembic(publish.Extractor, OptionalPyblishPluginMixin):
"frameEnd": end,
}
instance.data["representations"].append(representation)
self.log.info("Extracted instance '%s' to: %s" % (instance.name, path))
self.log.info(f"Extracted instance '{instance.name}' to: {path}")

View file

@ -1,14 +1,14 @@
import os
import pyblish.api
from openpype.pipeline import publish, OptionalPyblishPluginMixin
from pymxs import runtime as rt
from openpype.hosts.max.api import maintained_selection, get_all_children
from openpype.hosts.max.api import get_all_children, maintained_selection
from openpype.pipeline import OptionalPyblishPluginMixin, publish
class ExtractCameraFbx(publish.Extractor, OptionalPyblishPluginMixin):
"""
Extract Camera with FbxExporter
"""
"""Extract Camera with FbxExporter."""
order = pyblish.api.ExtractorOrder - 0.2
label = "Extract Fbx Camera"
@ -26,7 +26,7 @@ class ExtractCameraFbx(publish.Extractor, OptionalPyblishPluginMixin):
filename = "{name}.fbx".format(**instance.data)
filepath = os.path.join(stagingdir, filename)
self.log.info("Writing fbx file '%s' to '%s'" % (filename, filepath))
self.log.info(f"Writing fbx file '{filename}' to '{filepath}'")
rt.FBXExporterSetParam("Animation", True)
rt.FBXExporterSetParam("Cameras", True)
@ -36,10 +36,10 @@ class ExtractCameraFbx(publish.Extractor, OptionalPyblishPluginMixin):
with maintained_selection():
# select and export
rt.select(get_all_children(rt.getNodeByName(container)))
rt.exportFile(
rt.Select(get_all_children(rt.GetNodeByName(container)))
rt.ExportFile(
filepath,
rt.name("noPrompt"),
rt.Name("noPrompt"),
selectedOnly=True,
using=rt.FBXEXP,
)
@ -55,6 +55,4 @@ class ExtractCameraFbx(publish.Extractor, OptionalPyblishPluginMixin):
"stagingDir": stagingdir,
}
instance.data["representations"].append(representation)
self.log.info(
"Extracted instance '%s' to: %s" % (instance.name, filepath)
)
self.log.info(f"Extracted instance '{instance.name}' to: {filepath}")

View file

@ -1,20 +1,15 @@
import os
import pyblish.api
from openpype.pipeline import (
publish,
OptionalPyblishPluginMixin
)
from pymxs import runtime as rt
from openpype.hosts.max.api import (
maintained_selection
)
from openpype.hosts.max.api import maintained_selection
from openpype.pipeline import OptionalPyblishPluginMixin, publish
class ExtractModelUSD(publish.Extractor,
OptionalPyblishPluginMixin):
"""
Extract Geometry in USDA Format
"""
"""Extract Geometry in USDA Format."""
order = pyblish.api.ExtractorOrder - 0.05
label = "Extract Geometry (USD)"
@ -44,7 +39,7 @@ class ExtractModelUSD(publish.Extractor,
with maintained_selection():
# select and export
node_list = instance.data["members"]
rt.select(node_list)
rt.Select(node_list)
rt.USDExporter.ExportFile(asset_filepath,
exportOptions=export_options,
contentSource=rt.Name("selected"),

View file

@ -1,15 +1,15 @@
import os
import pyblish.api
from openpype.pipeline import publish
from pymxs import runtime as rt
from openpype.hosts.max.api import (
maintained_selection
)
from openpype.hosts.max.api import maintained_selection
from openpype.pipeline import publish
class ExtractPointCloud(publish.Extractor):
"""
Extract PRT format with tyFlow operators
Extract PRT format with tyFlow operators.
Notes:
Currently only works for the default partition setting
@ -112,8 +112,7 @@ class ExtractPointCloud(publish.Extractor):
job_args.append(mode)
additional_args = self.get_custom_attr(operator)
for args in additional_args:
job_args.append(args)
job_args.extend(iter(additional_args))
prt_export = f"{operator}.exportPRT()"
job_args.append(prt_export)

View file

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import pyblish.api
from openpype.pipeline import PublishValidationError
from pymxs import runtime as rt
from openpype.pipeline import PublishValidationError
class ValidateModelContent(pyblish.api.InstancePlugin):
"""Validates Model instance contents.

24
poetry.lock generated
View file

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand.
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "acre"
@ -1456,13 +1456,11 @@ python-versions = ">=3.6"
files = [
{file = "lief-0.12.3-cp310-cp310-macosx_10_14_arm64.whl", hash = "sha256:66724f337e6a36cea1a9380f13b59923f276c49ca837becae2e7be93a2e245d9"},
{file = "lief-0.12.3-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:6d18aafa2028587c98f6d4387bec94346e92f2b5a8a5002f70b1cf35b1c045cc"},
{file = "lief-0.12.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d4f69d125caaa8d5ddb574f29cc83101e165ebea1a9f18ad042eb3544081a797"},
{file = "lief-0.12.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c078d6230279ffd3bca717c79664fb8368666f610b577deb24b374607936e9c1"},
{file = "lief-0.12.3-cp310-cp310-win32.whl", hash = "sha256:e3a6af926532d0aac9e7501946134513d63217bacba666e6f7f5a0b7e15ba236"},
{file = "lief-0.12.3-cp310-cp310-win_amd64.whl", hash = "sha256:0750b72e3aa161e1fb0e2e7f571121ae05d2428aafd742ff05a7656ad2288447"},
{file = "lief-0.12.3-cp311-cp311-macosx_10_14_arm64.whl", hash = "sha256:b5c123cb99a7879d754c059e299198b34e7e30e3b64cf22e8962013db0099f47"},
{file = "lief-0.12.3-cp311-cp311-macosx_10_14_x86_64.whl", hash = "sha256:8bc58fa26a830df6178e36f112cb2bbdd65deff593f066d2d51434ff78386ba5"},
{file = "lief-0.12.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:74ac6143ac6ccd813c9b068d9c5f1f9d55c8813c8b407387eb57de01c3db2d74"},
{file = "lief-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:04eb6b70d646fb5bd6183575928ee23715550f161f2832cbcd8c6ff2071fb408"},
{file = "lief-0.12.3-cp311-cp311-win32.whl", hash = "sha256:7e2d0a53c403769b04adcf8df92e83c5e25f9103a052aa7f17b0a9cf057735fb"},
{file = "lief-0.12.3-cp311-cp311-win_amd64.whl", hash = "sha256:7f6395c12ee1bc4a5162f567cba96d0c72dfb660e7902e84d4f3029daf14fe33"},
@ -1482,7 +1480,6 @@ files = [
{file = "lief-0.12.3-cp38-cp38-win_amd64.whl", hash = "sha256:b00667257b43e93d94166c959055b6147d46d302598f3ee55c194b40414c89cc"},
{file = "lief-0.12.3-cp39-cp39-macosx_10_14_arm64.whl", hash = "sha256:e6a1b5b389090d524621c2455795e1262f62dc9381bedd96f0cd72b878c4066d"},
{file = "lief-0.12.3-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:ae773196df814202c0c51056163a1478941b299512b09660a3c37be3c7fac81e"},
{file = "lief-0.12.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:66ddf88917ec7b00752687c476bb2771dc8ec19bd7e4c0dcff1f8ef774cad4e9"},
{file = "lief-0.12.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:4a47f410032c63ac3be051d963d0337d6b47f0e94bfe8e946ab4b6c428f4d0f8"},
{file = "lief-0.12.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbd11367c2259bd1131a6c8755dcde33314324de5ea029227bfbc7d3755871e6"},
{file = "lief-0.12.3-cp39-cp39-win32.whl", hash = "sha256:2ce53e311918c3e5b54c815ef420a747208d2a88200c41cd476f3dd1eb876bcf"},
@ -2355,7 +2352,7 @@ files = [
cffi = ">=1.4.1"
[package.extras]
docs = ["sphinx (>=1.6.5)", "sphinx-rtd-theme"]
docs = ["sphinx (>=1.6.5)", "sphinx_rtd_theme"]
tests = ["hypothesis (>=3.27.0)", "pytest (>=3.2.1,!=3.3.0)"]
[[package]]
@ -3248,21 +3245,6 @@ files = [
[package.dependencies]
six = "*"
[[package]]
name = "wemake-python-styleguide"
version = "0.0.1"
description = "Opinionated styleguide that we use in wemake.services projects"
category = "dev"
optional = false
python-versions = "*"
files = [
{file = "wemake-python-styleguide-0.0.1.tar.gz", hash = "sha256:e1f47a2be6aa79ca8a1cfbbbffdd67bf4df32b76306f4c3dd2a620a2af78e671"},
{file = "wemake_python_styleguide-0.0.1-py2.py3-none-any.whl", hash = "sha256:505a19d82f9c4f450c6f06bb8c74d86c99cabcc4d5e6d8ea70e90b13b049f34f"},
]
[package.dependencies]
flake8 = "*"
[[package]]
name = "wheel"
version = "0.38.4"
@ -3480,4 +3462,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools"
[metadata]
lock-version = "2.0"
python-versions = ">=3.9.1,<3.10"
content-hash = "45e91b47f9e6697b0eb9fdbe76981f691d389ce74bc5a0e98d72e1109b39bc63"
content-hash = "02daca205796a0f29a0d9f50707544e6804f32027eba493cd2aa7f175a00dcea"

146
setup.cfg
View file

@ -1,6 +1,7 @@
[flake8]
# ignore = D203
ignore = BLK100, W504, W503
max-line-length = 79
strictness = short
exclude =
.git,
__pycache__,
@ -9,149 +10,8 @@ exclude =
website,
openpype/vendor,
*deadline/repository/custom/plugins
max-complexity = 30
ignore =
# line break before binary operator
W503,
# line break occurred after a binary operator
W504,
# wemake-python-styleguide warnings
# See https://wemake-python-stylegui.de/en/latest/pages/usage/violations/index.html for doc
# Found incorrect module name pattern
WPS102,
# Found wrong variable name
WPS110,
# Found too short name
WPS111,
# Found upper-case constant in a class
WPS115,
# Found module with too many imports
WPS201,
# Found too many module members
WPS202,
# Found overused expression
WPS204,
# Found too many local variables
WPS210,
# Found too many arguments
WPS211,
# Found too many return statements
WPS212,
# Found too many expressions
WPS213,
# Found too many methods
WPS214,
# Found too many await expressions
WPS217,
# Found line with high Jones Complexity
WPS221,
# Found too many `elif` branches
WPS223,
# Found string constant over-use
WPS226,
# Found too long try body length
WPS229,
# Found too many public instance attributes
WPS230,
# Found function with too much cognitive complexity
WPS231,
# Found module cognitive complexity that is too high
WPS232,
# Found too many imported names from a module
WPS235,
# Found too many raises in a function
WPS238,
# Found too deep nesting
WPS220,
# Found `f` string
WPS305,
# Found incorrect multi-line parameters
WPS317,
# Found extra indentation
WPS318,
# Found bracket in wrong position
WPS319,
# Found percent string formatting
WPS323,
# Found implicit string concatenation
WPS326,
# Found variables that are only used for `return`
WPS331,
# Found explicit string concatenation
WPS336,
# Found multiline conditions
WPS337,
# Found incorrect order of methods in a class
WPS338,
# Found line starting with a dot
WPS348,
# Found multiline loop
WPS352,
# Found incorrect unpacking target
WPS414,
# Found wrong keyword
WPS420,
# Found wrong function
WPS421,
# Found statement that has no effect
WPS428,
# Found nested function
WPS430,
# Found magic number
WPS432,
# Found protected attribute usage
WPS437,
# Found block variables overlap
WPS440,
# Found an infinite while loop
WPS457,
# Found a getter without a return value
WPS463,
# Found negated condition
WPS504,
# flake8-quotes warnings
# Remove bad quotes
Q000,
# Remove bad quotes from multiline string
Q001,
# Darglint warnings
# Incorrect indentation
DAR003,
# Excess parameter(s) in Docstring
DAR102,
# Excess exception(s) in Raises section
DAR402,
# pydocstyle warnings
# Missing docstring in __init_
D107,
# White space formatting for doc strings
D2,
# First line should end with a period
D400,
# Others
# function name
N802,
# Found backslash that is used for line breaking
N400,
E501,
S105,
RST,
# Black would make changes error
BLK100,
# Imperative mood of the first line on docstrings
D401,
[isort]
profile=wemake
src_paths=isort,test
# isort configuration:
# https://github.com/timothycrosley/isort/wiki/isort-Settings
include_trailing_comma = true
use_parentheses = true
# See https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output = 3
# Is the same as 80 in flake8:
line_length = 79
max-complexity = 30
[pylint.'MESSAGES CONTROL']
disable = no-member