c# . net is there a way to determine if a line/ arc have labels attached to it ?

c# . net is there a way to determine if a line/ arc have labels attached to it ?

jeff.wangD95HG
Collaborator Collaborator
124 Views
3 Replies
Message 1 of 4

c# . net is there a way to determine if a line/ arc have labels attached to it ?

jeff.wangD95HG
Collaborator
Collaborator

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.

0 Likes
Accepted solutions (1)
125 Views
3 Replies
Replies (3)
Message 2 of 4

Jeff_M
Consultant
Consultant
Accepted solution

From the CivilDocument you can use the GetGeneralSegmentLabelIds() method. Loop through those getting the Labels, from those you can save a list of the FeatureIds. Then you can check that list whether it contains the line/arc ObjectId, if not, delete it.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4

donna641flint
Community Visitor
Community Visitor

@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.

0 Likes
Message 4 of 4

jeff.wangD95HG
Collaborator
Collaborator

great i think that works after some brief testing

0 Likes