Skip to content

Commit

Permalink
Handling null TDF Label - Fix Issue #618
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Jun 12, 2024
1 parent ad55863 commit 8a3ee82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/build123d/exporters3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_exporters3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 8a3ee82

Please sign in to comment.