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.
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().