From 92063693e846eaceac51ea4232e0bfaab3d65c28 Mon Sep 17 00:00:00 2001 From: Cedric Steiert Date: Sat, 20 Jul 2024 01:36:23 +0200 Subject: [PATCH] add checks for NoneType to ignore empty shape nodes creating a pull request for proposed solution from https://projects.blender.org/blender/blender-addons/issues/87766, where a few Shape nodes are missing a coord and coordIndex Section (which would result in an import error) --- source/import_x3d.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/import_x3d.py b/source/import_x3d.py index 4c21551..6864bae 100644 --- a/source/import_x3d.py +++ b/source/import_x3d.py @@ -1878,6 +1878,10 @@ def importMesh_IndexedFaceSet(geom, ancestry): ccw = geom.getFieldAsBool('ccw', True, ancestry) coord = geom.getChildBySpec('Coordinate') + + if coord is None: + return None + if coord.reference: points = coord.getRealNode().parsed # We need unflattened coord array here, while @@ -3142,6 +3146,10 @@ def importShape(bpycollection, node, ancestry, global_matrix): if geom_fn is not None: bpydata = geom_fn(geom, ancestry) + if bpydata is None: + print('ImportX3D warning: empty shape, skipping node "%s"' % vrmlname) + return + # There are no geometry importers that can legally return # no object. It's either a bpy object, or an exception importShape_ProcessObject( -- 2.30.2