methodik für 3d Polylinine implmentiert

This commit is contained in:
2025-06-30 13:53:55 +02:00
parent e75779cfcb
commit 812c39b00d
+28 -12
View File
@@ -329,8 +329,8 @@ def get_rack_positions(msp):
#print_polyline(e)
rack_key = f"Rack_{rack_counter}"
ret[rack_key] = list()
for x, y, start_width, end_width, bulge in e.get_points(): # Gibt Tuple (x, y, start_width, end_width, bulge)
p = [round(x,1), round(y,1)]
for x, y, z, start_width, end_width, bulge in e.get_points(): # Gibt Tuple (x, y, start_width, end_width, bulge)
p = [round(x,1), round(y,1), round(z,1)]
ret[rack_key].append(p)
rack_counter +=1
return ret
@@ -343,26 +343,42 @@ def get_rack_positions_iter(dxf_path):
all_layers = config.items('GetPos-Layer_Racks')
for entity in iterdxf.modelspace(dxf_path):
if entity.dxftype() != "LWPOLYLINE":
continue
layer = entity.dxf.layer
if not any(layer == cfg_layer for cfg_layer, _ in all_layers):
continue
continue
rack_key = f"Rack_{rack_counter}"
ret[rack_key] = []
# Verwende entity.vertices() statt get_points()
for point in entity.vertices(): # (x, y, start_width, end_width, bulge)
x, y, *_ = point # wir interessieren uns nur für x und y
ret[rack_key].append([round(x, 1), round(y, 1)])
if entity.dxftype() == "LWPOLYLINE":
handle_lwpolyline(entity, rack_key, ret)
elif entity.dxftype() == "POLYLINE":
handle_polyline(entity, rack_key, ret)
else:
continue
rack_counter += 1
return ret
def handle_lwpolyline(entity, rack_key, ret):
"""Verarbeitet eine 2D LWPOLYLINE mit globalem Z-Wert (elevation)."""
z = getattr(entity.dxf, "elevation", 0.0) # hole "Erhebung" (gilt für gesamte Polyline!) aus Attributen
ret[rack_key] = []
for point in entity.vertices(): # returns (x, y, start_width, end_width, bulge)
x, y, *_ = point
ret[rack_key].append([round(x, 1), round(y, 1), round(z, 1)])
def handle_polyline(entity, rack_key, ret):
"""Verarbeitet eine klassische POLYLINE inklusive 3D-Polylinien mit individuellen Z-Werten."""
ret[rack_key] = []
for vertex in entity.vertices:
x = vertex.dxf.location.x
y = vertex.dxf.location.y
z = vertex.dxf.location.z
ret[rack_key].append([round(x, 1), round(y, 1), round(z, 1)])
def scan(dxf_source:ezdxf.document.Drawing):
layer_names_inside = dxf_source.layers.entries.keys()
alle_block_defs = set(dxf_source.blocks.block_names())