Schalter --copy_layer inklusive Funktionen rausgeschmissen. Wird nicht mehr benutzt, bzw. dauert zu lange um alle Referenzen eines Layers mit zu kopieren
This commit is contained in:
+4
-31
@@ -97,22 +97,7 @@ def modify_original_dxf(plines, originaldxf):
|
||||
doc.saveas(out_path)
|
||||
print("done")
|
||||
|
||||
def copy_layers_into_new(originaldxf, outpath, plines):
|
||||
""" creates a new dxf file with a racks, sensors, subdists from original file including cable paths
|
||||
"""
|
||||
print("copying layers (Racks, Subdistributors, ...) from original .dxf into new .dxf ..")
|
||||
|
||||
quelle = ezdxf.readfile(originaldxf)
|
||||
ziel = ezdxf.new('R2018', setup=True)
|
||||
|
||||
draw_cables(plines, ziel)
|
||||
draw_sensors(plines, ziel)
|
||||
copy_layers_into_dxf_by_filter(quelle, ziel)
|
||||
|
||||
|
||||
ziel.saveas(out_path)
|
||||
print("done")
|
||||
|
||||
def draw_cables(plines, doc):
|
||||
msp = doc.modelspace()
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
|
||||
@@ -695,9 +680,11 @@ def map_sensor_to_cable_cfg(plines):
|
||||
sensor_name = '-'.join(pl.id.split('-')[1:])
|
||||
cable_length = round(pl.length/1000, 1)
|
||||
sensor_artinr = pl.s_artinr
|
||||
# SPS Prefex
|
||||
name_prefix = sensor_name[:2]
|
||||
|
||||
# Suche nach Key in der BMK-Config
|
||||
|
||||
key_with_artnr = f"{name_prefix}-{sensor_artinr}" # Spezialfälle über "Key mit Artikelnummer" abgleichen
|
||||
if key_with_artnr in mapping:
|
||||
section_list = mapping[key_with_artnr]
|
||||
@@ -705,6 +692,8 @@ def map_sensor_to_cable_cfg(plines):
|
||||
section_list = mapping[name_prefix]
|
||||
else:
|
||||
sens2cable[pl.id].append("Kein Kabeltyp zugewiesen (BMK.cfg)")
|
||||
section_list = list()
|
||||
# TODO was soll hier passieren wenn die Config falsch ist?
|
||||
|
||||
# Liste aus evtl. mehreren Sektionen erzeugen
|
||||
sections = [s.strip() for s in section_list.split(",")]
|
||||
@@ -726,7 +715,6 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='draws a dxf file with the given cable coordinates', prog='drawdxf')
|
||||
parser.add_argument('-f', '--filename', action='store', required=True, help='this json file contains all cables and its coordinates which should be drawn. Saved with an unique timestamp', metavar='myfile.json')
|
||||
parser.add_argument('-d', '--dxf', action='store', help='this dxf drawing will be copied and the new layer with the cables will be added. Original file must be added with --origin', metavar='myfile.dxf')
|
||||
parser.add_argument('-c', '--copy_layer', action='store', help='copy layers of racks, sensors, distributors into a new .dxf-file. File also contains cable paths. Original file must be added with --origin', metavar='original.dxf')
|
||||
parser.add_argument('-n', '--new', action='store', help='create a new dxf file only with cables in it. Name is basename and a timestamp')
|
||||
parser.add_argument('-x', '--excel', action='store', help='create a xlsx file with cables data', metavar='allCables.xls')
|
||||
parser.add_argument('-o', '--origin', action='store', help='name of original .dxf file used by -d and -a', metavar='original.dxf')
|
||||
@@ -770,14 +758,6 @@ if __name__ == '__main__':
|
||||
|
||||
dxf_file = args.dxf
|
||||
|
||||
if args.dxf or args.copy_layer:
|
||||
if not args.origin:
|
||||
parser.print_help()
|
||||
exit()
|
||||
else:
|
||||
(origin_path, dexists) = check_file_in_work(work_dir, args.origin)
|
||||
|
||||
|
||||
if args.dxf:
|
||||
(dxf_path, dexists) = check_file_in_work(work_dir, dxf_file)
|
||||
if not dexists:
|
||||
@@ -787,13 +767,6 @@ if __name__ == '__main__':
|
||||
out_path = dxf_path
|
||||
res_pos = new_dxf(plines, dxf_path)
|
||||
|
||||
if args.copy_layer:
|
||||
|
||||
out_path = os.path.join(work_dir, args.copy_layer)
|
||||
res_pos = new_dxf(plines, out_path)
|
||||
|
||||
copy_layers_into_new(origin_path, out_path, plines)
|
||||
|
||||
if args.new:
|
||||
# erzeuge dxf Datei nur mit Kabeln
|
||||
out_path = os.path.join(work_dir, args.new)
|
||||
|
||||
Reference in New Issue
Block a user