The command to assign a Global Coordinate System in Autocad Map3D 2015 is MAPCSASSIGN. My question is how do I set this programatically using ObjectArx? Here is my failed attempt at doing so:
// Start a transaction
using (Transaction tr = db.TransactionManager.StartTransaction())
{
// Open the UCS table for read
UcsTable ut = tr.GetObject(db.UcsTableId, OpenMode.ForRead) as UcsTable;
// Open the UCS table record Model space for write (Get Existing EPSG 4269)
UcsTableRecord utr = tr.GetObject(ut["4269"], OpenMode.ForWrite) as UcsTableRecord;
// Open the active viewport
ViewportTableRecord acVportTblRec = tr.GetObject(doc.Editor.ActiveViewportId, OpenMode.ForWrite) as ViewportTableRecord;
// Set the UCS current
acVportTblRec.SetUcs(utr.ObjectId);
doc.Editor.UpdateTiledViewportsFromDatabase();
// Display the name of the current UCS
UcsTableRecord acUCSTblRecActive = tr.GetObject(acVportTblRec.UcsName, OpenMode.ForRead) as UcsTableRecord;
acApp.ShowAlertDialog("The current UCS is: " + acUCSTblRecActive.Name);
// Save the new object(s) to the database
tr.Commit();
}
But I am getting a key not found error. Any help would be appreciated. Thanks