How to Offset Dimensions Dynamically from Polyline Based on Annotation Scale

How to Offset Dimensions Dynamically from Polyline Based on Annotation Scale

santhoshr151194
Contributor Contributor
152 Views
1 Reply
Message 1 of 2

How to Offset Dimensions Dynamically from Polyline Based on Annotation Scale

santhoshr151194
Contributor
Contributor

I’m placing aligned dimensions along polyline segments using the AutoCAD .NET API. Right now, I position each dimension with a fixed perpendicular offset from the polyline, which works fine at first.

However, I’ve made the dimensions annotative to keep the text readable across layout viewports with different scales. As a result, the dimension text grows larger in some viewports, and the fixed offset causes the text to overlap with the polyline.

I’m looking for a way to offset dimensions dynamically based on annotation scale, so the spacing adjusts automatically and keeps the text clear and readable in all viewports.

Any best practices for dimensioning polylines like this when annotation scales are involved?

Any guidance would be appreciated — thanks!

0 Likes
153 Views
1 Reply
Reply (1)
Message 2 of 2

fieldguy
Advisor
Advisor

See if this helps.  You can obtain the "Current" annoscale with this.

// check the TextStyleTableRecord for annotative 
acdb.TextStyleTableRecord tstr = (acdb.TextStyleTableRecord)tr.GetObject(mystyleid,    acdb.OpenMode.ForRead);
double tsize = tstr.TextSize;
if (tsize == 0.0)
tsize = 2;
bool annotative = false;
if (tstr.Annotative == acdb.AnnotativeStates.True)
annotative = true;
double tsize = tstr.TextSize;
if (tsize == 0.0)
tsize = 2;
if (annotative)
{        
acdb.ObjectContextManager ocm = db.ObjectContextManager;
acdb.ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
acdb.AnnotationScale asc = (acdb.AnnotationScale)occ.CurrentContext;
double psunits = asc.PaperUnits;
double msunits = asc.DrawingUnits;
double annofactor = 1;
if (asc.Name != "Model")
  annofactor = msunits / psunits;
tsize = msunits / psunits * 2;
}// change size if annotative textstyle
 
I use a factor of 2 for calculating the insertion point later on. I create a new point3d by offsetting the midpoint of a line (or linesegment) using "annofactor".

 

0 Likes