From de0049085d95100a2fae74365627177a6138ea9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 13 May 2024 16:54:49 +0200 Subject: [PATCH] :art: add OBJ options --- .../hosts/maya/plugins/publish/extract_obj.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/maya/plugins/publish/extract_obj.py b/client/ayon_core/hosts/maya/plugins/publish/extract_obj.py index dfa2ae1c77..72e716b430 100644 --- a/client/ayon_core/hosts/maya/plugins/publish/extract_obj.py +++ b/client/ayon_core/hosts/maya/plugins/publish/extract_obj.py @@ -20,6 +20,15 @@ class ExtractObj(publish.Extractor): label = "Extract OBJ" families = ["model"] + # OBJ export options + obj_options = { + "groups": 1, + "ptgroups": 1, + "materials": 1, + "smoothing": 1, + "normals": 1, + } + def process(self, instance): # Define output path @@ -47,6 +56,8 @@ class ExtractObj(publish.Extractor): cmds.loadPlugin('objExport') strip_shader = instance.data.get("strip_shaders", True) + if strip_shader: + self.obj_options["materials"] = 0 # Export with lib.no_display_layers(instance): @@ -57,12 +68,13 @@ class ExtractObj(publish.Extractor): pointsShaded=1, polygonObject=1): with lib.shader(members, - shadingEngine="initialShadingGroup") if strip_shader else nullcontext(): # noqa: E501: + shadingEngine="initialShadingGroup") if strip_shader else nullcontext(): # noqa: E501 with lib.maintained_selection(): cmds.select(members, noExpand=True) cmds.file(path, exportSelected=True, type='OBJexport', + op=';'.join(f"{key}={val}" for key, val in self.obj_options.items()), # noqa: E501 preserveReferences=True, force=True)