Code: Select all
using System;
using CADImport;
using CADImport.Export.DirectCADtoDXF;
namespace DeleteEntity
{
class Program
{
static void Main(string[] args)
{
#region CAD Import .NET Registration
<font color="green">// Enter the registration information for CAD Import .NET </font id="green">library.
System.Collections.ArrayList regDat = new System.Collections.ArrayList();
regDat.Add("xxxxx");
regDat.Add("xxxxx@objectiveworld.com");
CADImport.Protection.Register("XXXXXXXXX", regDat, false);
#endregion
<font color="green">// Load the cad drawing from file.</font id="green">
CADImage cadDrawing = new CADImage();
cadDrawing.LoadFromFile("input.dxf");
cadDrawing.SelectionMode = SelectionEntityMode.Disabled;
cadDrawing.UseDoubleBuffering = true;
<font color="green">// The name of the layer that we wish to remove.</font id="green">
string layerName = "green";
foreach (string entityKey in cadDrawing.Converter.Entities.AllKeys)
{
CADEntity entity = (CADEntity)cadDrawing.Converter.Entities[entityKey];
<font color="green">// Remove the entity if it belongs to the layer that we want to remove.</font id="green">
if (entity.Layer.Name == layerName)
{
cadDrawing.RemoveEntity(entity);
}
}
<font color="green">// Save result to output.dxf.</font id="green">
CADtoDXF exportImage = new CADtoDXF(cadDrawing);
exportImage.SaveToFile("output.dxf");
}
}
}