From 8bda4ddfa54fbb040d7aa1eb75c7443d35d9d636 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Thu, 10 Jul 2025 15:28:29 +0200 Subject: [PATCH] Import: DXF, make straight polylines Draft-editable --- src/Mod/Draft/importDXF.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index b67a0f7fbf..8e7dd3b6b7 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -4629,6 +4629,24 @@ class DxfDraftPostProcessor: new_obj = self.doc.addObject("Part::Part2DObjectPython", self.doc.getUniqueObjectName("Wire")) new_obj.Shape = shape # Transfer the TopoDS_Wire from the original Part::Feature. Draft.Wire(new_obj) # Attach Python proxy. It will find Shape, Placement. + + # Check if all segments of the wire are straight lines. + # If so, we can safely populate the .Points property to make it parametric. + # Otherwise, we do nothing, leaving it as a non-parametric but geometrically correct shape. + is_all_lines = True + + for edge in shape.Edges: + if edge.Curve.TypeId == "Part::GeomLine": + continue # This is a straight segment + else: + is_all_lines = False + break # Found a curve, no need to check further + + if is_all_lines and shape.OrderedVertexes: + # All segments are straight, so we can make it an editable wire + points = [v.Point for v in shape.OrderedVertexes] + new_obj.Points = points + new_obj.Closed = shape.isClosed() # Transfer specific properties expected by Draft.Wire. obj_type_str = "Wire"