@jeff.wangD95HG choiceadvantage comwrote:
I basically want to write a function that cleans up the drawing by deleting duplicates, but I don't want it to delete any linework that already got labelled. So how do I go about doing this?
the function should run through all the line /arcs that the user has selected and determine if any duplication line/arc exist and delete the line/arc that doesn't have a generalsegement label attached to it.
The `cleanup_drawing.py` script is a function designed to delete duplicate lines and arcs from a user's selection while preserving any that have a "generalsegment" label. It works by creating a unique geometric key for each object to identify duplicates, then iterates through the selection, keeping the first object of a kind it finds. If a duplicate is found, the script checks if either object has the specified label; if only one does, that labeled object is preserved, and the unlabeled one is deleted. If neither or both have the label, the new duplicate is deleted. The code includes placeholder functions that must be replaced with the specific API calls of the user's CAD application.