diff --git a/lib/getpositions.py b/lib/getpositions.py index 467e677..801ec30 100644 --- a/lib/getpositions.py +++ b/lib/getpositions.py @@ -230,6 +230,16 @@ def get_rack_positions(msp): # print_polyline(e) return ret +def scan(dxf_source:ezdxf.document.Drawing): + layer_names_inside = dxf_source.layers.entries.keys() + alle_block_defs = set(dxf_source.blocks.block_names()) + used_block_names = set(insert.dxf.name for insert in dxf_source.modelspace().query("INSERT")) + ret = dict() + ret['all_layers'] = layer_names_inside + ret['used_blocks'] = used_block_names + ret['all_blocks'] = alle_block_defs + return ret + def to_json(d, pretty: bool = True) -> str: return json.dumps(d, indent=2 if pretty else None, ensure_ascii=False, default=str) #ensure_ascii false für darstellung von "ue" @@ -265,6 +275,7 @@ if __name__ == '__main__': parser.add_argument('-r', '--rack', action='store_true', help='fetch all positions of all cable racks') parser.add_argument('-w', '--write', action='store', help='write results into a json file') parser.add_argument('-c', '--console', action='store_true', help='print results to output') + parser.add_argument('-n', '--scan', action='store_true', help='print all layer of racs, distributes and equiment not empty') args = parser.parse_args() @@ -272,13 +283,19 @@ if __name__ == '__main__': out_dir = os.environ.get('PROJECT_DATA') work_dir = os.environ.get('PROJECT_WORK') config_dir = os.environ.get("PROJECT_CFG") - filename = args.filename + filename = args.filename (dxf_path, dexists) = check_file_in_work(work_dir, filename) + doc = get_dxf_file(dxf_path) # type: ignore msp = doc.modelspace() + if args.scan: + res = scan(doc) + print(to_json(res)) + sys.exit() + res_pos = dict() res_dist = dict() res_rac = dict()