自动桌子的代码,有看[url=http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html]http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html[/url]
么?
同一内容最好不要重开贴:)- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
-
- [CommandMethod("CreateText")]
- public static void CreateText()
- {
- // Get the current document and database
- Document acDoc = Application.DocumentManager.MdiActiveDocument;
- Database acCurDb = acDoc.Database;
-
- // Start a transaction
- using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
- {
- // Open the Block table for read
- BlockTable acBlkTbl;
- acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
- OpenMode.ForRead) as BlockTable;
-
- // Open the Block table record Model space for write
- BlockTableRecord acBlkTblRec;
- acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
-
- // Create a single-line text object
- DBText acText = new DBText();
- acText.SetDatabaseDefaults();
- acText.Position = new Point3d(2, 2, 0);
- acText.Height = 0.5;
- acText.TextString = "Hello, World.";
-
- acBlkTblRec.AppendEntity(acText);
- acTrans.AddNewlyCreatedDBObject(acText, true);
-
- // Save the changes and dispose of the transaction
- acTrans.Commit();
- }
- }
|