You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingAutodesk.AutoCAD.ApplicationServices;usingAutodesk.AutoCAD.DatabaseServices;DocumentacDoc=Application.DocumentManager.MdiActiveDocument;Databasedb=acDoc.Database;// Lock document before modifyingusing(DocumentLockdocLock=acDoc.LockDocument()){using(Transactiontr=db.TransactionManager.StartTransaction()){// Modify database objects heretr.Commit();}}
Example 3: Executing Commands
usingAutodesk.AutoCAD.ApplicationServices;DocumentacDoc=Application.DocumentManager.MdiActiveDocument;// Execute a commandacDoc.SendStringToExecute("ZOOM E ",true,false,false);
Example 4: Saving Document
usingAutodesk.AutoCAD.ApplicationServices;usingAutodesk.AutoCAD.DatabaseServices;DocumentacDoc=Application.DocumentManager.MdiActiveDocument;Databasedb=acDoc.Database;// Save current documentdb.SaveAs(acDoc.Name,DwgVersion.Current);// Or save with new namedb.SaveAs("C:\\Drawings\\NewName.dwg",DwgVersion.Current);
Example 5: Using User Data
usingAutodesk.AutoCAD.ApplicationServices;DocumentacDoc=Application.DocumentManager.MdiActiveDocument;// Store custom data with documentacDoc.UserData["MyKey"]="MyValue";// Retrieve custom dataif(acDoc.UserData.Contains("MyKey")){stringvalue=acDoc.UserData["MyKey"]asstring;ed.WriteMessage($"\nStored value: {value}");}