NetCad 2.2.0.2
See the version list below for details.
dotnet add package NetCad --version 2.2.0.2
NuGet\Install-Package NetCad -Version 2.2.0.2
<PackageReference Include="NetCad" Version="2.2.0.2" />
paket add NetCad --version 2.2.0.2
#r "nuget: NetCad, 2.2.0.2"
// Install NetCad as a Cake Addin #addin nuget:?package=NetCad&version=2.2.0.2 // Install NetCad as a Cake Tool #tool nuget:?package=NetCad&version=2.2.0.2
这是一个CAD Api接口二次封装的库,用于快速开发CAD插件
作者:ZhangFuWang
Email:fuwang.zhang@qq.com
支持 Auto CAD 2013-2023
[Github仓库地址](zhangfuwang666/NetCad (github.com))
<u>软件类型App</u>
获取当前软件的文件夹路径
public static string CurrentFolder
获取当前的文件路径
public static string DocumentFolder
加载dll
public static void LoadDll(string dllName)
是否是新建的文档
public static bool IsDocumentNew(Document doc = null)
文档是否保存
public static bool IsDocumentSaved(Document doc = null)
获取所有打开的文档
public static List<Document> GetAllOpenedDocuments()
加锁执行
public static void LockAndExecute(Action action)
public static void LockAndExecute(Document doc, Action action)
设置当前的文档
public static void SetActiveDocument(Document doc)
设置工作文档
public static void SetWorkingDatabase(Database db)
打开文档
public static Document OpenDocument(string file)
打开文档并设置激活文档
public static Document OpenOrActivateDocument(string file)
<u>数据库操作 DbHelper</u>
获取表内的所有对象Id集合
public static ObjectId[] GetSymbolTableRecords(ObjectId symbolTableId)
获取表内所有的对象的名称集合
public static string[] GetSymbolTableRecordNames(ObjectId symbolTableId)
获取图层的Id
public static ObjectId GetLayerId(string layerName, Database db = null)
获取所有图层的名称
public static string[] GetAllLayerNames(Database db = null)
确保图层开启
public static void EnsureLayerOn(string layerName)
public static ObjectId GetBlockId(string blockName, Database db = null)
获取块表的Id集合
public static ObjectId[] GetAllBlockIds(Database db = null)
获取块表内所有块的名称
public static string[] GetAllBlockNames(Database db = null)
获取指定线性的名称
public static ObjectId GetLinetypeId(string linetypeName, Database db = null)
获取文字样式Id
public static ObjectId GetTextStyleId(string textStyleName, bool createIfNotFound = false, Database db = null)
获取标注样式Id
public static ObjectId GetDimstyleId(string dimStyleName, Database db = null)
public static ObjectId GetDictionaryObject(ObjectId dictionaryId, string name, ObjectId? defaultValue = null, Func<DBObject> create = null)
获取组名称
public static ObjectId GetGroupId(string groupName, Database db = null)
根据实体获取组的Id
public static ObjectId GetGroupId(ObjectId entityId)
获取组内实体的Id集合
public static IEnumerable<ObjectId> GetEntityIdsInGroup(ObjectId groupId)
获取对象xdata的第一个数据
public static string GetFirstXData(this ObjectId dboId, string appName)
public static string GetFirstXData(this DBObject dbo, string appName)
public static object GetFirstXDataT(this DBObject dbo, string appName)
设置对象xdata的第一个数据
public static void SetFirstXData(this ObjectId dboId, string appName, string value)
public static void SetFirstXData(this DBObject dbo, string appName, string value)
public static void SetFirstXDataT(this DBObject dbo, string appName, object value)
public static void SetFirstXDataT(this ObjectId dboId, string appName, object value)
添加应用拓展数据
public static void AffirmRegApp(params string[] appNames)
public static void AffirmRegApp(Database db, params string[] appNames)
设置默认拓展代码(appname:"TongJiCode")
public static void SetCode(this Entity entity, string code)
public static void SetCode(this ObjectId entityId, string code)
获取默认拓展代码(appname:"TongJiCode")
public static string GetCode(this Entity entity)
public static string GetCode(this ObjectId entityId)
获取块参照的所有属性参照Id集合
public static Dictionary<string, ObjectId> GetBlockAttributeIds(this BlockReference blockReference)
获取块参照的所有属性参照键值对集合
public static Dictionary<string, string> GetBlockAttributes(this BlockReference blockReference)
获取块参照的指定属性参照值
public static string GetBlockAttribute(this BlockReference blockReference, string tag)
给块定义添加属性定义
public static void DefineBlockAttribute(string blockName, string tag, string value, string prompt, Point3d position, ObjectId style)
给块参照添加属性参照
public static void AppendAttribute(this BlockReference blockReference, AttributeReference attributeReference, bool overwrite = true, bool createIfMissing = true)
获取指定对象的指定字典的指定键值
public static string GetData(this ObjectId id, string dict, string key)
设置指定对象的指定字典的指定键值
public static void SetData(this ObjectId id, string dict, string key, string value)
判断 TongJiTags应用内是否包含某个值
public static bool HasTag(this DBObject dbo, string tag)
public static bool HasTag(this ObjectId id, string tag)
TongJiTags应用添加标签
public static void AddTag(this DBObject dbo, string tag)
public static void AddTag(this ObjectId id, string tag)
移除TongJiTags应用添加标签
public static void RemoveTag(this DBObject dbo, string tag)
public static void RemoveTag(this ObjectId id, string tag)
初始化注册应用信息(添加
"TongJiCode", "TongJiID", "TongJiName", "TongJiTags")注册表
public static void InitializeDatabase(Database db = null)
<u>交互类 Interaction</u>
获取当前Editor
public static Editor ActiveEditor
Editor打印信息
public static void Write(string message)
public static void Write(string message, params object[] args)
Editor换行打印
public static void WriteLine(string message)
public static void WriteLine(string message, params object[] args)
Editor获取字符串
public static string GetString(string message)
public static string GetString(string message, string defaultValue)
Editor获取关键字
public static string GetKeywords(string message, string[] keywords, int defaultIndex = 0)
Editor获取数值
public static double GetValue(string message, double? defaultValue = null)
Editor获取距离
public static double GetDistance(string message)
Editor获取角度
public static double GetAngle(string message)
Editor获取点
public static Point3d GetPoint(string message)
Editor获取线的终点
public static Point3d GetLineEndPoint(string message, Point3d startPoint)
Editor获取角点
public static Point3d GetCorner(string message, Point3d basePoint)
Editor获取拓展包围
public static Extents3d? GetExtents(string message)
Editor获取一个实体
public static ObjectId GetEntity(string message)
public static ObjectId GetEntity(string message, Type allowedType, bool exactMatch = true)
Editor获取一个实体和选取实体的点
public static Tuple<ObjectId, Point3d> GetPick(string message)
Editor获取多个实体
public static ObjectId[] GetSelection(string message, params TypedValue[] filterList)
public static ObjectId[] GetSelection(string message, FilterList filterList)
public static ObjectId[] GetSelection(string message, string allowedType) 手动写选取的类型,只能写一个类型
Editor获取矩形范围内多个实体,可以筛选
public static ObjectId[] GetWindowSelection(Point3d pt1, Point3d pt2, string allowedType = "*")
Editor获取矩形相交多个实体,可以筛选
public static ObjectId[] GetCrossingSelection(Point3d pt1, Point3d pt2, string allowedType = "*")GetPickSet()
Editor获取已有的选择集
public static ObjectId[] GetPickSet()
Editor设置选择对象
public static void SetPickSet(ObjectId[] entityIds)
Editor选择最后添加的对象
public static ObjectId GetNewestEntity()
public static ObjectId[] GetNewestEntities()
设置当前文档获取焦点
public static void SetActiveDocFocus()
设置当前的图层
public static void SetCurrentLayer(string layerName)
发送内部命令
public static void Command(string command)
public static void StartCommand(string command)
高亮对象
public static void HighlightObjects(IEnumerable<ObjectId> entityIds)
取消高亮对象
public static void UnhighlightObjects(IEnumerable<ObjectId> entityIds)
对象居中
public static void ZoomObjects(IEnumerable<ObjectId> entityIds)
public static void ZoomView(Extents3d extents)
public static void ZoomExtents()
动态插入实体
public static ObjectId InsertEntity(Entity entity, string message = "\nSpecify insert point")
动态缩放插入实体
public static ObjectId InsertScalingEntity(Entity entity, Point3d basePoint, string message = "\nSpecify diagonal point")
动态旋转插入实体
public static ObjectId InsertRotationEntity(Entity entity, Point3d center, string message = "\nSpecify direction")
调用系统保存文件窗体
public static string SaveFileDialogBySystem(string title, string fileName, string filter)
调用系统保存文件窗体
public static string OpenFileDialogBySystem(string title, string fileName, string filter)
调用系统选择文件夹窗体
public static string FolderDialog(string description)
调用选择颜色窗体
public static Color ColorDialog()
绘制多段线
public static Polyline GetPromptPolyline(string message)
居中显示高亮的实体
public static void ZoomHighlightView(List<ObjectId> entityIds, Action<int> action = null)
<u>算法类 Algorithms</u>
<u>拓展数据 CustomDictionary</u>
<u>拓展数据 CustomObjectDictionary</u>
<u>实体生成类 NoDraw</u> (不加入模型空间)
两点生成直线
public static Line Line(Point3d point1, Point3d point2)
多点生成多条直线
public static Line[] Line(params Point3d[] points)
三点画圆弧
public static Arc Arc3P(Point3d point1, Point3d point2, Point3d point3)
起点,圆心,角度绘制圆弧
public static Arc ArcSCA(Point3d start, Point3d center, double angle)
圆
public static Circle Circle(Point3d center, double radius)
圆心和点画圆
public static Circle Circle(Point3d center, Point3d pointOnCircle)
三点画圆
public static Circle Circle(Point3d point1, Point3d point2, Point3d point3)
椭圆
public static Ellipse Ellipse(Point3d center, Point3d endX, double radiusY)
多段线
public static Polyline Polyline(params Point3d[] points)
多段线
public static Polyline Polyline(IEnumerable<Point3d> points, double globalWidth = 0.0)
多段线
public static Polyline Polyline(List<Tuple<Point3d, double>> vertices, double globalWidth = 0.0)
样条曲线
public static Spline SplineFit(Point3d[] points)
样条曲线
public static Spline SplineCV(Point3d[] points, bool closed = false)
绘制矩形
public static Polyline Rectang(Point3d minPoint, Point3d maxPoint)
单行文字
public static DBText Text(string text, double height, Point3d position, double rotation = 0.0, bool centerAligned = false, string textStyle = "AutoCADCodePackTextStyle")
多行文字
public static MText MText(string text, double height, Point3d position, double rotation = 0.0, bool centerAligned = false, double width = 0.0)
点
public static DBPoint Point(Point3d position)
块参照
public static BlockReference Insert(ObjectId blockTableRecordId, Point3d position, double rotation = 0.0, double scale = 1.0)
绘制实体 Draw(加入模型空间)
public static ObjectId Point(Point3d position)
public static ObjectId[] Divide(Curve curve, int number, Entity entity)
public static ObjectId[] Measure(Curve curve, double interval, Entity entity)
public static ObjectId Line(Point3d point1, Point3d point2)
public static ObjectId[] Line(params Point3d[] points)
public static ObjectId Arc3P(Point3d point1, Point3d point2, Point3d point3)
public static ObjectId ArcSCA(Point3d start, Point3d center, double angle)
public static ObjectId Polyline(params Point3d[] points)
public static ObjectId Polyline(IEnumerable<Point3d> points, double globalWidth = 0.0)
public static ObjectId Polyline(List<Tuple<Point3d, double>> vertices, double globalWidth = 0.0)
public static ObjectId SplineFit(Point3d[] points)
public static ObjectId SplineCV(Point3d[] points, bool closed = false)
public static ObjectId Rectang(Point3d point1, Point3d point2)
public static ObjectId Polygon(int n, Point3d center, Point3d end)
public static ObjectId Circle(Point3d center, double radius)
public static ObjectId Circle(Point3d point1, Point3d point2)
public static ObjectId Circle(Point3d point1, Point3d point2, Point3d point3)
public static ObjectId Circle(CircularArc3d circle)
public static ObjectId Circle(CircularArc2d circle)
public static ObjectId Ellipse(Point3d center, Point3d endX, double radiusY)
public static ObjectId Hatch(string hatchName, Point3d seed)
public static ObjectId Hatch(string hatchName, Entity[] entities)
public static ObjectId Hatch(ObjectId[] loopIds, string hatchName = "SOLID", double scale = 1.0, double angle = 0.0, bool associative = false)
public static ObjectId Hatch(IEnumerable<Point3d> points, string hatchName = "SOLID", double scale = 1.0, double angle = 0.0)
public static ObjectId Boundary(Point3d seed, BoundaryType type)
public static ObjectId Region(ObjectId curveId)
public static ObjectId Text(string text, double height, Point3d position, double rotation = 0.0, bool centerAligned = false, string textStyle = "AutoCADCodePackTextStyle")
public static ObjectId MText(string text, double height, Point3d position, double rotation = 0.0, bool centerAligned = false, double width = 0.0)
public static ObjectId Wipeout(params Point3d[] points)
public static ObjectId Wipeout(ObjectId entityId)
public static ObjectId Wipeout(Extents3d extents)
public static ObjectId Insert(string blockName, Point3d position, double rotation = 0.0, double scale = 1.0)
public static ObjectId Block(IEnumerable<ObjectId> entityIds, string blockName)
public static ObjectId Block(IEnumerable<ObjectId> entityIds, string blockName, Point3d basePoint, bool overwrite = true)
public static ObjectId Block(IEnumerable<Entity> entities, string blockName, Point3d basePoint, bool overwrite = true)
public static ObjectId CreateBlockAndInsertReference(IEnumerable<Entity> entities, string blockName, Point3d blockBasePoint, Point3d insertPosition, double rotation = 0.0, double scale = 1.0, bool overwrite = true)
public static ObjectId BlockInDwg(string blockName, string sourceDwg)
public static ObjectId BlockOfDwg(string blockName, string sourceDwg)
public static ObjectId Table(Point3d position, string title, List<List<string>> contents, double rowHeight, double columnWidth, double textHeight, string textStyle = "AutoCADCodePackTextStyle")
public static ObjectId PolygonMesh(List<Point3d> points, int m, int n, bool mClosed = false, bool nClosed = false)
public static ObjectId Dimlin(Point3d start, Point3d end, Point3d dim)
public static ObjectId AddToModelSpace(this Entity ent)
大部分时间使用加入当前空间
public static ObjectId AddToCurrentSpace(this Entity entity, Database db = null)
<u>日志管理类 LogManager</u>
写日志
public static void Write(object o)
public static void Write(string note, object o)
<u>日志表 public class LogTable</u>
public LogTable(params int[] colWidths)
public string GetRow(params object[] contents)
public static int GetStringWidth(string content)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- AutoCAD.NET (>= 20.0.0 && <= 24.0.0)
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 |
---|---|---|
2.2.0.3 | 177 | 4/17/2024 |
2.2.0.2 | 125 | 3/27/2024 |
2.2.0.1 | 111 | 3/27/2024 |
2.2.0 | 106 | 3/22/2024 |
2.1.0 | 111 | 2/29/2024 |
2.0.12 | 91 | 2/29/2024 |
2.0.11 | 188 | 12/22/2023 |
2.0.10 | 124 | 12/22/2023 |
2.0.0.9 | 158 | 12/6/2023 |
2.0.0.8 | 119 | 12/6/2023 |
2.0.0.7 | 135 | 12/3/2023 |
2.0.0.6 | 124 | 12/3/2023 |
2.0.0.5 | 125 | 12/2/2023 |
2.0.0.4 | 136 | 12/1/2023 |
2.0.0.3 | 140 | 11/16/2023 |
2.0.0.2 | 112 | 11/16/2023 |
2.0.0.1 | 115 | 11/15/2023 |
2.0.0 | 108 | 11/15/2023 |
1.0.0.4 | 116 | 11/14/2023 |
1.0.0.3 | 567 | 1/20/2022 |
1.0.0.2 | 431 | 1/20/2022 |
1.0.0.1 | 423 | 1/20/2022 |
更新图标.