Я использую эти разработчики Руководство, которое я нашел для AutoCAD .NET и скопировал пример на странице 67, однако я получаю сообщение об ошибке «Пространство имен не может напрямую содержать элементы, такие как поля или методы» в этой строке:
public static void ListEntities()
Это код, который у меня есть в Visual Studio:
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("ListEntities")]
public static void ListEntities()
{ // Get the current document and database, and start a transaction
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{ // Open the Block table record for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for read
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForRead) as BlockTableRecord;
int nCnt = 0;
acDoc.Editor.WriteMessage("\nModel space objects: ");
// Step through each object in Model space and
// display the type of object found
foreach (ObjectId acObjId in acBlkTblRec)
{ acDoc.Editor.WriteMessage("\n" + acObjId.ObjectClass.DxfName);
nCnt = nCnt + 1;
}
// If no objects are found then display a message
if (nCnt == 0) {
acDoc.Editor.WriteMessage("\n No objects found");
}
// Dispose of the transaction
}
}
У меня есть ссылки на решение Accoremgd.dll, acdbmgd.dll и acmgd.dll.