The GstarCAD port of Gile.AutoCAD.Extension. This is an unofficial extension library enhanced for GstarCAD .NET SDK.
You can get GstarCAD SDK on the official website https://www.gstarcad.com/download/, or on the Nuget Gallery.
Example with a method to erase lines in model space which are smaller than a given distance:
public void EraseShortLines(double minLength)
{
var db = Application.DocumentManager.MdiActiveDocument.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
var modelSpace = (BlockTableRecord)tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead);
var lineClass = RXObject.GetClass(typeof(Line));
foreach (ObjectId id in modelSpace)
{
if (id.ObjectClass == lineClass)
{
var line = (Line)tr.GetObject(id, OpenMode.ForRead);
if (line.Length < minLength)
{
tr.GetObject(id, OpenMode.ForWrite);
line.Erase();
}
}
}
tr.Commit();
}
}
The same method can be written:
public void EraseShortLines(double minLength)
{
var db = Active.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
db.GetModelSpace()
.GetObjects<Line>()
.Where(line => line.Length < minLength)
.UpgradeWrite()
.ToList()
.ForEach(line => line.Erase());
tr.Commit();
}
}
> build.bat
If 'msbuild' is not recognized, please set compilation environment firstly.
This library is published as a nuget package in nuget.org.