diff --git a/src/Mod/FreeCADExchange/AutoRouting.py b/src/Mod/FreeCADExchange/AutoRouting.py index 395ae5a..5ae7e55 100644 --- a/src/Mod/FreeCADExchange/AutoRouting.py +++ b/src/Mod/FreeCADExchange/AutoRouting.py @@ -1165,9 +1165,15 @@ def route_all_from_payload(doc, payload, options=None): report["routes"].append( { "wire_uuid": _wire_item_value(item, "wire_id", "wire_uuid", "id"), + "wire_label": _wire_item_value(item, "wire_label", "wire_mark"), + "wire_style_id": _wire_item_value(item, "wire_style_id"), + "start_terminal_uuid": start_uuid, + "end_terminal_uuid": end_uuid, "algorithm": result["algorithm"], "route_status": result["route_status"], "length_mm": route_length, + "lane": result.get("lane", {}), + "network": result.get("network", {}), "collision_count": result["collision_count"], } ) diff --git a/tests/python/freecad_exchange_auto_routing_test.py b/tests/python/freecad_exchange_auto_routing_test.py index 420a136..79ef112 100644 --- a/tests/python/freecad_exchange_auto_routing_test.py +++ b/tests/python/freecad_exchange_auto_routing_test.py @@ -1028,6 +1028,49 @@ class AutoRoutingTest(unittest.TestCase): self.assertEqual(report["total_length_mm"], report["routes"][0]["length_mm"]) self.assertIn("总长度", message) + def test_route_all_report_keeps_route_identity_and_diagnostics(self): + _install_fake_freecad() + terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules() + app = sys.modules["FreeCAD"] + doc = FakeDocument() + terminal_objects.ensure_root_group(doc, "project-1") + _terminal(doc, terminal_objects, "TerminalStart", "terminal-start", app.Vector(0, 0, 0)) + _terminal(doc, terminal_objects, "TerminalEnd", "terminal-end", app.Vector(100, 0, 0)) + routing_network.create_route_carrier( + doc, + [app.Vector(0, 0, 20), app.Vector(100, 0, 20)], + project_uuid="project-1", + kind="WireDuct", + ) + payload = { + "project_uuid": "project-1", + "wires": [ + { + "wire_id": "wire-1", + "wire_label": "N4111", + "wire_style_id": "42", + "start_terminal_uuid": "terminal-start", + "end_terminal_uuid": "terminal-end", + } + ], + } + + report = auto_routing.route_all_from_payload( + doc, + payload, + options={"lane_spacing": 12.0, "lane_axis": "y"}, + ) + route = report["routes"][0] + + self.assertEqual("wire-1", route["wire_uuid"]) + self.assertEqual("N4111", route["wire_label"]) + self.assertEqual("42", route["wire_style_id"]) + self.assertEqual("terminal-start", route["start_terminal_uuid"]) + self.assertEqual("terminal-end", route["end_terminal_uuid"]) + self.assertEqual(0, route["lane"]["index"]) + self.assertEqual("network-dijkstra-v1", route["algorithm"]) + self.assertEqual(1, route["network"]["carriers"]) + def test_route_all_report_calls_out_local_unbound_terminals(self): _install_fake_freecad() terminal_objects, _wiring_objects, _routing_network, auto_routing = _reload_modules()