Message 1 of 7
Annotation Scale Sorting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the following code to add annocation scales.
public static void AddScale(string Name, double PaperUnits, double DrawingUnits)
{
try
{
ObjectContextManager ocm = HostApplicationServices.WorkingDatabase.ObjectContextManager;
if (ocm != null)
{
ObjectContextCollection occ =
ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
if (occ != null)
{
if (!(occ.HasContext(Name)))
{
// new scale
AnnotationScale annotationScale = new AnnotationScale();
annotationScale.Name = Name;
annotationScale.PaperUnits = PaperUnits;
annotationScale.DrawingUnits = DrawingUnits;
Editor ed = AcApp.DocumentManager.MdiActiveDocument.Editor;
//ed.WriteMessage(string.Format("\n{0}", annotationScale.Name));
//add to context collection
occ.AddContext(annotationScale);
}
}
}
}
catch (System.Exception ex)
{
AcApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString());
}
}
public static void ClearScaleList()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = AcApp.DocumentManager.MdiActiveDocument.Editor;
try
{
ObjectContextManager ocm = db.ObjectContextManager;
if (ocm != null)
{
ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
if (occ != null)
{
foreach (AnnotationScale anScale in occ)
{
if (!(occ.CurrentContext.Name.Equals(anScale.Name)))
{
//ed.WriteMessage("\n" + anScale.Name + " : removed");
occ.RemoveContext(anScale.Name);
}
}
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.ToString());
}
}When I run the folllowing code
Setup.ScaleList.ClearScaleList();
Setup.ScaleList.AddScale("1:1", 1,1);
Setup.ScaleList.AddScale("1:2", 1, 1);
Setup.ScaleList.AddScale("1:4", 1, 1);
Setup.ScaleList.AddScale("1:8", 1, 1);
Setup.ScaleList.AddScale("1:10", 1, 1);
Setup.ScaleList.AddScale("1:16", 1, 1);
Setup.ScaleList.AddScale("1:20", 1, 1);
Setup.ScaleList.AddScale("1:30", 1, 1);
Setup.ScaleList.AddScale("1:40", 1, 1);
Setup.ScaleList.AddScale("1:50", 1, 1);
Setup.ScaleList.AddScale("1:100", 1, 1);
Setup.ScaleList.AddScale("1:200", 1, 1);
Setup.ScaleList.AddScale("1:250", 1, 1);
Setup.ScaleList.AddScale("1:500", 1, 1);
Setup.ScaleList.AddScale("1:1000", 1, 1);
Setup.ScaleList.AddScale("1:2000", 1, 1);
Setup.ScaleList.AddScale("1:5000", 1, 1);
Setup.ScaleList.AddScale("1:10000", 1, 1);
Setup.ScaleList.AddScale("1:20000", 1, 1);
Setup.ScaleList.AddScale("1:50000", 1, 1);
Setup.ScaleList.AddScale("1:100000", 1, 1);
Setup.ScaleList.AddScale("1:200000", 1, 1);
Setup.ScaleList.AddScale("1:250000", 1, 1);
Setup.ScaleList.AddScale("1:500000", 1, 1); it adds all of the scales, but they are displayed in this order
1:2
1:100
1:200
1:250
1:500
1:1000
1:2000
1:5000
1:10000
1:20000
1:50000
1:4
1:100000
1:200000
1:250000
1:500000
1:8
1:10
1:16
1:20
1:30
1:40
1:50
1:1
Is there a way to sort Annotation scales?
Thanks