不是很清楚,我也刚学没多久。下面是原代码你再试一下
我是用VS2019 C#写的,目标框架4.5,调用的库是ObjectARX 2016。我电脑上之有CAD2021,运行没有问题。
- [CommandMethod("DJTC")]
- public void DJTC()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- using(Transaction trans = db.TransactionManager.StartTransaction())
- {
- LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead);
- foreach (ObjectId id in lt)
- {
- LayerTableRecord ltr = (LayerTableRecord)trans.GetObject(id, OpenMode.ForWrite);
- if (ltr.IsPlottable == false) ltr.IsFrozen = true;
- ltr.DowngradeOpen();
- }
- trans.Commit();
- }
- }
|