private void SetStyleAnnotative(DimStyleTableRecord[] resultStyleName, DBObject item, Dimension y) { AnnotationScale mainScale = new AnnotationScale(); ObjectContextManager ocm = targetDB.ObjectContextManager; double scale = 2.5 / (y.Dimscale * y.Dimtxt); double difference = 200; if (ocm != null) { ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES"); ObjectContext currentContext = occ.CurrentContext; foreach (ObjectContext context in occ) { double currentDifference = 200; AnnotationScale annotScale = (AnnotationScale)context; if (annotScale.Scale == scale) { mainScale = annotScale; break; } else { currentDifference = Math.Abs(scale - annotScale.Scale); if (currentDifference < difference) { difference = currentDifference; mainScale = annotScale; } } } SetStyleByType(resultStyleName, item, y); if (y.HasContext(currentContext)) { y.RemoveContext(currentContext); } y.AddContext(mainScale); y.Dimtxt = 2.5; } }
private void SetStyleAnnotative(DimStyleTableRecord[] resultStyleName, DBObject item, Dimension y) { AnnotationScale mainScale = new AnnotationScale(); ObjectContextManager ocm = targetDB.ObjectContextManager; double scale = 2.5 / (y.Dimscale * y.Dimtxt); double difference = 200; if (ocm != null) { ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES"); ObjectContext currentContext = occ.CurrentContext; foreach (ObjectContext context in occ) { double currentDifference = 200; AnnotationScale annotScale = (AnnotationScale)context; if (annotScale.Scale == scale) { mainScale = annotScale; break; } else { currentDifference = Math.Abs(scale - annotScale.Scale); if (currentDifference < difference) { difference = currentDifference; mainScale = annotScale; } } } SetStyleByType(resultStyleName, item, y); if (y.HasContext(currentContext)) y.RemoveContext(currentContext); y.AddContext(mainScale); y.Dimtxt = 2.5; } }