Sharper.GstarCAD.Extensions 2024.3.0

dotnet add package Sharper.GstarCAD.Extensions --version 2024.3.0
NuGet\Install-Package Sharper.GstarCAD.Extensions -Version 2024.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sharper.GstarCAD.Extensions" Version="2024.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sharper.GstarCAD.Extensions --version 2024.3.0
#r "nuget: Sharper.GstarCAD.Extensions, 2024.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sharper.GstarCAD.Extensions as a Cake Addin
#addin nuget:?package=Sharper.GstarCAD.Extensions&version=2024.3.0

// Install Sharper.GstarCAD.Extensions as a Cake Tool
#tool nuget:?package=Sharper.GstarCAD.Extensions&version=2024.3.0

Sharper.GstarCAD.Extensions

GstarCAD Extension Library

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.

This library should help to write code in a more concise and declarative way.

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();
    }
}

Deployment

This library is published as a nuget package in nuget.org.

Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.3.0 92 3/13/2024
2024.2.0 127 12/29/2023
2024.1.0 155 11/6/2023
2022.2.0 86 3/13/2024
2022.1.0 215 10/30/2022