From 6495d9540e65e7d171932e0e3fa41a45db83c091 Mon Sep 17 00:00:00 2001 From: Octave Crespel Date: Thu, 7 Dec 2023 16:21:29 +0100 Subject: [PATCH 1/3] Add .x3d/.wrl support --- src/panels.py | 6 +++++- src/stop_motion_obj.py | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/panels.py b/src/panels.py index 6720374..3885322 100644 --- a/src/panels.py +++ b/src/panels.py @@ -140,7 +140,9 @@ class SequenceImportSettings(bpy.types.PropertyGroup): fileFormat: bpy.props.EnumProperty( items=[('obj', 'OBJ', 'Wavefront OBJ'), ('stl', 'STL', 'STereoLithography'), - ('ply', 'PLY', 'Stanford PLY')], + ('ply', 'PLY', 'Stanford PLY'), + ('x3d', 'X3D/WRL', 'X3D/WRL file'), + ], name='File Format', default='obj') dirPathIsRelative: bpy.props.BoolProperty( @@ -279,6 +281,8 @@ def draw(self, context): layout.row().prop(op.importSettings, "stl_use_facet_normal") elif op.sequenceSettings.fileFormat == 'ply': layout.label(text="No .ply settings") + elif op.sequenceSettings.fileFormat == 'x3d': + layout.label(text="No .x3d/.wrl settings") class SMO_PT_TransformSettingsPanel(bpy.types.Panel): diff --git a/src/stop_motion_obj.py b/src/stop_motion_obj.py index 0817617..b21451d 100644 --- a/src/stop_motion_obj.py +++ b/src/stop_motion_obj.py @@ -236,6 +236,8 @@ def load(self, fileType, filePath): self.loadSTL(filePath) elif fileType == 'ply': self.loadPLY(filePath) + elif fileType == 'x3d': + self.loadX3D(filePath) def loadOBJ(self, filePath): # call the obj load function with all the correct parameters @@ -282,6 +284,10 @@ def loadPLY(self, filePath): # call the ply load function with all the correct parameters bpy.ops.import_mesh.ply(filepath=filePath) + def loadX3D(self, filePath): + # call the X3D load function with all the correct parameters + bpy.ops.import_scene.x3d(filepath=filePath) + class MeshNameProp(bpy.types.PropertyGroup): key: bpy.props.StringProperty() @@ -323,7 +329,9 @@ class MeshSequenceSettings(bpy.types.PropertyGroup): fileFormat: bpy.props.EnumProperty( items=[('obj', 'OBJ', 'Wavefront OBJ'), ('stl', 'STL', 'STereoLithography'), - ('ply', 'PLY', 'Stanford PLY')], + ('ply', 'PLY', 'Stanford PLY'), + ('x3d', 'X3D/WRL', 'X3D/WRL file'), + ], name='File Format', default='obj') From 3986a64ddcb20675f891bbeaaa8806c01d19170c Mon Sep 17 00:00:00 2001 From: Octave Crespel Date: Thu, 7 Dec 2023 16:59:50 +0100 Subject: [PATCH 2/3] Show .wrl files in explorer, and delete non-mesh data from the wrl import --- src/panels.py | 2 +- src/stop_motion_obj.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panels.py b/src/panels.py index 3885322..86d44be 100644 --- a/src/panels.py +++ b/src/panels.py @@ -162,7 +162,7 @@ class ImportSequence(bpy.types.Operator, ImportHelper): sequenceSettings: bpy.props.PointerProperty(type=SequenceImportSettings) # for now, we'll just show any file type that Stop Motion OBJ supports - filter_glob: bpy.props.StringProperty(default="*.stl;*.obj;*.mtl;*.ply") + filter_glob: bpy.props.StringProperty(default="*.stl;*.obj;*.mtl;*.ply;*.wrl;*.x3d") directory: bpy.props.StringProperty(subtype='DIR_PATH') diff --git a/src/stop_motion_obj.py b/src/stop_motion_obj.py index b21451d..4747a57 100644 --- a/src/stop_motion_obj.py +++ b/src/stop_motion_obj.py @@ -162,6 +162,8 @@ def fileExtensionFromType(_type): return 'stl' elif(_type == 'ply'): return 'ply' + elif(_type == 'x3d'): + return 'wrl' return '' @@ -287,6 +289,10 @@ def loadPLY(self, filePath): def loadX3D(self, filePath): # call the X3D load function with all the correct parameters bpy.ops.import_scene.x3d(filepath=filePath) + for obj in bpy.context.selected_objects: + if obj.type != 'MESH': + print('deleting ', obj) + bpy.data.objects.remove(obj) class MeshNameProp(bpy.types.PropertyGroup): From a46b607bb2f8df2d1fbaa4163044c47059eac307 Mon Sep 17 00:00:00 2001 From: Octave Crespel Date: Thu, 7 Dec 2023 17:46:02 +0100 Subject: [PATCH 3/3] Remove all mentions of 'x3d', load WRL files only for now --- src/panels.py | 8 ++++---- src/stop_motion_obj.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/panels.py b/src/panels.py index 86d44be..0b0595d 100644 --- a/src/panels.py +++ b/src/panels.py @@ -141,7 +141,7 @@ class SequenceImportSettings(bpy.types.PropertyGroup): items=[('obj', 'OBJ', 'Wavefront OBJ'), ('stl', 'STL', 'STereoLithography'), ('ply', 'PLY', 'Stanford PLY'), - ('x3d', 'X3D/WRL', 'X3D/WRL file'), + ('wrl', 'WRL', 'WRL file'), ], name='File Format', default='obj') @@ -162,7 +162,7 @@ class ImportSequence(bpy.types.Operator, ImportHelper): sequenceSettings: bpy.props.PointerProperty(type=SequenceImportSettings) # for now, we'll just show any file type that Stop Motion OBJ supports - filter_glob: bpy.props.StringProperty(default="*.stl;*.obj;*.mtl;*.ply;*.wrl;*.x3d") + filter_glob: bpy.props.StringProperty(default="*.stl;*.obj;*.mtl;*.ply;*.wrl") directory: bpy.props.StringProperty(subtype='DIR_PATH') @@ -281,8 +281,8 @@ def draw(self, context): layout.row().prop(op.importSettings, "stl_use_facet_normal") elif op.sequenceSettings.fileFormat == 'ply': layout.label(text="No .ply settings") - elif op.sequenceSettings.fileFormat == 'x3d': - layout.label(text="No .x3d/.wrl settings") + elif op.sequenceSettings.fileFormat == 'wrl': + layout.label(text="No .wrl settings") class SMO_PT_TransformSettingsPanel(bpy.types.Panel): diff --git a/src/stop_motion_obj.py b/src/stop_motion_obj.py index 4747a57..261158a 100644 --- a/src/stop_motion_obj.py +++ b/src/stop_motion_obj.py @@ -162,7 +162,7 @@ def fileExtensionFromType(_type): return 'stl' elif(_type == 'ply'): return 'ply' - elif(_type == 'x3d'): + elif(_type == 'wrl'): return 'wrl' return '' @@ -238,8 +238,8 @@ def load(self, fileType, filePath): self.loadSTL(filePath) elif fileType == 'ply': self.loadPLY(filePath) - elif fileType == 'x3d': - self.loadX3D(filePath) + elif fileType == 'wrl': + self.loadWRL(filePath) def loadOBJ(self, filePath): # call the obj load function with all the correct parameters @@ -286,8 +286,8 @@ def loadPLY(self, filePath): # call the ply load function with all the correct parameters bpy.ops.import_mesh.ply(filepath=filePath) - def loadX3D(self, filePath): - # call the X3D load function with all the correct parameters + def loadWRL(self, filePath): + # call the WRL load function with all the correct parameters bpy.ops.import_scene.x3d(filepath=filePath) for obj in bpy.context.selected_objects: if obj.type != 'MESH': @@ -336,7 +336,7 @@ class MeshSequenceSettings(bpy.types.PropertyGroup): items=[('obj', 'OBJ', 'Wavefront OBJ'), ('stl', 'STL', 'STereoLithography'), ('ply', 'PLY', 'Stanford PLY'), - ('x3d', 'X3D/WRL', 'X3D/WRL file'), + ('wrl', 'WRL', 'WRL file'), ], name='File Format', default='obj')