Public Shared Sub CreateUCS(origin As Point3d, x_axis As Vector3d, y_axis As Vector3d) '' Get the current document and database, and start a transaction Dim acDoc As Document = _AcAp.Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() '' Open the UCS table for read Dim acUCSTbl As UcsTable acUCSTbl = acTrans.GetObject(acCurDb.UcsTableId, OpenMode.ForRead) Dim acUCSTblRec As UcsTableRecord '' Check to see if the "New_UCS" UCS table record exists If acUCSTbl.Has("New_UCS") = False Then acUCSTblRec = New UcsTableRecord() acUCSTblRec.Name = "New_UCS" '' Open the UCSTable for write acUCSTbl.UpgradeOpen() '' Add the new UCS table record acUCSTbl.Add(acUCSTblRec) acTrans.AddNewlyCreatedDBObject(acUCSTblRec, True) Else acUCSTblRec = acTrans.GetObject(acUCSTbl("New_UCS"), OpenMode.ForWrite) End If acUCSTblRec.Origin = origin 'New Point3d(4, 5, 3) acUCSTblRec.XAxis = x_axis 'New Vector3d(1, 0, 0) acUCSTblRec.YAxis = y_axis 'New Vector3d(0, 1, 0) '' Open the active viewport Dim acVportTblRec As ViewportTableRecord acVportTblRec = acTrans.GetObject(acDoc.Editor.ActiveViewportId, OpenMode.ForWrite) '' Display the UCS Icon at the origin of the current viewport acVportTblRec.IconAtOrigin = True acVportTblRec.IconEnabled = True '' Set the UCS current acVportTblRec.SetUcs(acUCSTblRec.ObjectId) acDoc.Editor.UpdateTiledViewportsFromDatabase() '' Display the name of the current UCS Dim acUCSTblRecActive As UcsTableRecord acUCSTblRecActive = acTrans.GetObject(acVportTblRec.UcsName, OpenMode.ForRead) _AcAp.Application.ShowAlertDialog("The current UCS is: " & acUCSTblRecActive.Name) '' Save the new objects to the database acTrans.Commit() End Using End Sub