diff --git a/src/build123d/exporters3d.py b/src/build123d/exporters3d.py index 6c44cf64..5a29f8ce 100644 --- a/src/build123d/exporters3d.py +++ b/src/build123d/exporters3d.py @@ -135,7 +135,7 @@ def _create_xde(to_export: Shape, unit: Unit = Unit.MM) -> TDocStd_Document: shape_tool.FindShape(sub_node, findInstance=False) for sub_node in sub_nodes ] - if node.label: + if node.label and not node_label.IsNull(): TDataStd_Name.Set_s(node_label, TCollection_ExtendedString(node.label)) if node.color is not None: diff --git a/tests/test_exporters3d.py b/tests/test_exporters3d.py index 6af0d53b..22281ef6 100644 --- a/tests/test_exporters3d.py +++ b/tests/test_exporters3d.py @@ -31,6 +31,7 @@ import unittest from typing import Optional +from bd_warehouse.thread import TrapezoidalThread from build123d.build_common import GridLocations from build123d.build_enums import Unit from build123d.build_line import BuildLine @@ -141,6 +142,18 @@ def test_export_step_unknown(self): os.chmod("box_read_only.step", 0o777) # Make the file read/write os.remove("box_read_only.step") + def test_export_step_null_label(self): + # Moving the object creates a null TDF_Label + testobj = TrapezoidalThread( + diameter=20, + pitch=1.5, + length=20, + thread_angle=30.0, + ) + testobj_moved = testobj.moved(Pos(0, 0, 10)) + self.assertTrue(export_step(testobj_moved, "test.step")) + os.remove("test.step") + class TestExportGltf(DirectApiTestCase): def test_export_gltf(self):