Drawing Cleanup

AutoCAD Map 3D .NET API

 
Drawing Cleanup
 
 
 

Drawing cleanup is essential for polygon and network topologies. It ensures that the objects in the topology can be connected properly. For more details about the various types of cleanup actions, refer to the UI documentation.

A drawing cleanup operation involves combining one or more cleanup actions. Each action is identified by an action number. Many of the actions have additional settings.

Action Description Settings
1 Erase Short Objects CLEAN_TOL
2 Break Crossing Objects  
4 Extend Undershoots CLEAN_TOL

?? break target

8 Delete Duplicates CLEAN_TOL

INCLUDE_LINEAROBJS

INCLUDE_POINTS

INCLUDE_BLOCKS

INCLUDE_TEXT

INCLUDE_MTEXT

INCLUDE_ROTATION

INCLUDE_ZVALUES

16 Snap Clustered Nodes CLEAN_TOL

INCLUDE_POINTS

INCLUDE_BLOCKS

SNAP_TO_NODE

32 Dissolve Pseudo Nodes  
64 Erase Dangling Objects CLEAN_TOL
128 Simplify Objects CLEAN_TOL

???create arcs

256 Zero Length Objects  
512 Apparent Intersection CLEAN_TOL
1024 Weed Polylines WEED_DISTANCE

WEED_ANGLE

WEED_SUPPLEMENT_DISTANCE

WEED_SUPPLEMENT_BULGE

The same class, Topology.Variable, is used for both actions and settings. To create a drawing cleanup action, create a settings variable and set its values:

Dim toleranceVal As New DatabaseServices.TypedValue _
(Autodesk.AutoCAD.DatabaseServices.DxfCode.Real, 25.5)
Dim toleranceSetting As New DatabaseServices.ResultBuffer
toleranceSetting.Add(toleranceVal)
 
Dim blocksVal As New DatabaseServices.TypedValue _
(Autodesk.AutoCAD.DatabaseServices.DxfCode.Int16, 1)
Dim blocksSetting As New DatabaseServices.ResultBuffer
blocksSetting.Add(blocksVal)
 
Dim settings As New Topology.Variable
settings.Set("CLEAN_TOL", toleranceSetting)
settings.Set("INCLUDE_BLOCKS", blocksSetting)

Create an action variable and add the action and its settings:

Dim action As New Topology.Variable
action.InsertActionToList(-1, 8, settings)

If the operation will include more than one action, repeat the process and insert more actions and their corresponding settings into the same action variable.

To perform the cleanup, create a TopologyClean object and initialize it with the action variable and a set of drawing objects to clean.

Dim cleanObj As New Topology.TopologyClean
cleanObj.Init(action, Nothing)

Each individual action in the action variable is a cleanup group. Start the cleanup and go through the groups until all actions have been completed. Commit the changes using TopologyClean.End().

cleanObj.Start()
cleanObj.GroupNext()
Do While Not cleanObj.Completed
   cleanObj.GroupFix()
   cleanObj.GroupNext()
Loop
cleanObj.End()

For finer control over the objects being cleaned, step through the errors in a group using TopologyClean.ErrorCur(). Fix or ignore each one individually. Set TopologyClean.ErrorPoint to change the location for the fix.

To save a profile for later use, call Variable.SaveProfile() using an action variable object. To reload the profile, call Variable.LoadProfile().