我可以通过AutoCAD .NET API添加/删除CAD实体吗?

问题描述 投票:0回答:1

需要使用.NET API在CAD绘图中添加/删除在标题栏区域中绘制为单个CAD实体的项目,该项目不是属性。有没有办法在CAD图纸或任何其他方法上使用点引用,这可以通过API完成?

已要求CAD实体删除图像,客户端地址和网址。

用它来访问属性

BlockTableRecord blkTblRecTitle = 
    transaction.GetObject(blockTable[BlockTableRecord.PaperSpace], 
       OpenMode.ForWrite) as BlockTableRecord;
        foreach (ObjectId id in blkTblRecTitle)
        {
            DBObject obj = transaction.GetObject(id, OpenMode.ForWrite);
            BlockReference blkRef = obj as BlockReference;
            if (blkRef != null)
            {
                AttributeCollection attCol = blkRef.AttributeCollection;
                foreach (ObjectId objID in attCol)
                {
                    DBObject dbObj = transaction.GetObject(objID, 
                          OpenMode.ForWrite) as DBObject;

                    AttributeReference acAttRef = dbObj as 
                    AttributeReference;
                 }
             }
          }

设法找到如何在一个位置添加多行文本

using (MText acText = new MText())
{
       acText.Location = new Point3d(802, 106.5, 0);
       acText.TextHeight = 2;
       acText.Contents = "Hello World.\nNow need to right align text.";

       blkTblRecTitle.AppendEntity(acText);
       transaction.AddNewlyCreatedDBObject(acText, true);
}

理想情况下,想要对齐,但无法在任何地方看到我如何使用必须用于多行的MText。

如果在Paper Space中添加文本时出现问题,则无法查看如何添加图像。

c# autocad
1个回答
1
投票

要编辑.DWG文件,您需要AutoCAD引擎,它可以是:

  1. 桌面:使用计算机上的现有AutoCAD,创建一个.NET / VBA / LISP / C ++插件,用于打开,读取,修改和保存文件。 Here is a .NET tutorial
  2. cloud:使用Forge Design Automation Web服务与您的文件一起运行自定义命令/例程。检查qazxsw poi。

然后我会建议查看博客documentationhere的示例代码。

© www.soinside.com 2019 - 2024. All rights reserved.