dst.CurrentStyle有误,请检查
时间: 2024-02-25 19:51:42 浏览: 98
非常抱歉,是我的疏忽导致了错误。正确的写法应该是 `db.Dimstyle`。以下是修改后的代码:
```csharp
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace GetCurrentDimensionStyleName
{
public class Commands
{
[CommandMethod("GetCurrentDimensionStyleName")]
public static void GetCurrentDimensionStyleName()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DimStyleTable dst = tr.GetObject(db.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;
DimStyleTableRecord currentDst = tr.GetObject(db.Dimstyle, OpenMode.ForRead) as DimStyleTableRecord;
ed.WriteMessage("\nCurrent default dimension style name: " + currentDst.Name);
tr.Commit();
}
}
}
}
```
该代码获取当前文档、编辑器和数据库,然后在事务中获取当前的标注样式表和默认标注样式记录,并输出当前默认标注样式的名称。
阅读全文