Wish : I want to delete multiple primaries eg layers quickly
Article | 60001764 |
Type | Wish |
Product | Engine |
Version | 6022 |
Date Added | 7/23/2012 |
Fixed | Yes [7/23/2012] |
Submitted by | Anirudha Sardesai |
Keywords | |
Subject
I want to delete multiple primaries eg layers quickly
Summary
We want to delete multiple primary objects.
Solution
Deleting a layer takes some time because the whole Document is searched to check if that layer has any reference.
We exported the following method in order to avoid checking the Document multiple times in order to delete multiple primaries (layers).
summary> This method should be used in order to delete multiple primaries objects. It is much faster than setting Deleted = true to the primary directly.
param name="layers">A
collection that contains the layers to be deleted or null if layers are not needed to be checked.
param name="blocks">A
collection that contains the blocks to be deleted or null if blocks are not needed to be checked.
param name="dimstyles">A
collection that contains the dimstyles to be deleted or null if dimstyles are not needed to be checked.
param name="linetypes">A
collection that contains the linetypes to be deleted or null if linetypes are not needed to be checked.
param name="textstyles">A
collection that contains the textstyles to be deleted or null if textstyles are not needed to be checked.
param name="images">A
collection that contains the images to be deleted or null if Image definitions are not needed to be checked.
param name="hatchpatterns">A
collection that contains the hatchpatterns to be deleted or null if hatch patterns are not needed to be checked.
public void DeleteUnusedTables(vdLayers layers, vdBlocks blocks, vdDimstyles dimstyles, vdLineTypes linetypes, vdTextstyles textstyles, vdImages images, vdHatchPatterns hatchpatterns)
This method can be used like below :
Example : Delete all layers with their entities that start with name VULCAN
vdDocument doc = vdFramedControl.BaseControl.ActiveDocument;
doc.UndoHistory.StoreUndoGroup(true);
vdLayers layers = new vdLayers();
foreach (vdLayer layer in doc.Layers)
{
if (!layer.Name.StartsWith("VULCAN")) continue;
foreach (vdFigure fig in layer.GetReferenceObjects()) fig.Deleted = true;
layers.AddItem(layer);
}
doc.DeleteUnusedTables(layers, null, null, null, null, null, null);
doc.UndoHistory.StoreUndoGroup(false);