Below C# code shows the procedure to add a scale to scale list.
[CommandMethod("AddScale")]
static public void addScale()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
// next get the objectContextManager
try
{
ObjectContextManager contextManager =
db.ObjectContextManager;
// if ok
if (contextManager != null)
{
// now get the Annotation Scaling context collection
// (named ACDB_ANNOTATIONSCALES_COLLECTION)
ObjectContextCollection contextCollection =
contextManager.GetContextCollection(
"ACDB_ANNOTATIONSCALES");
// if ok
if (contextCollection != null)
{
// create a brand new scale context
AnnotationScale annotationScale =
new AnnotationScale();
annotationScale.Name = "WBScale2 1:28";
annotationScale.PaperUnits = 1;
annotationScale.DrawingUnits = 28;
// now add to the drawing's context collection
contextCollection.AddContext(annotationScale);
}
}
}
catch (System.Exception ex)
{
Editor ed = doc.Editor;
ed.WriteMessage(ex.ToString());
}
}

Leave a Reply