The recommended method to expose a AutoCAD Civil 3D extension to users is to add it to the Toolbox tab in Toolspace, by creating a toolbox macro. The Toolbox handles loading the .NET assembly or ARX DLL containing the commands.
There are two execution types that a toolbox macro can have:
It is safe to explicitly lock a document, even if the code might be run in document context.
Here is an example of how to handle document locking:
static void setPrecision()
{
using (Autodesk.AutoCAD.ApplicationServices.DocumentLock locker = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
{
// perform any document / database modifications here
CivilApplication.ActiveDocument.Settings.DrawingSettings.AmbientSettings.Station.Precision.Value = 2;
}
}