Dimension Placement

Dimension Placement

Kyudos
Advisor Advisor
766 Views
5 Replies
Message 1 of 6

Dimension Placement

Kyudos
Advisor
Advisor

It's a long shot but....does anyone know the formula AutoCAD uses to position the text for an AcDbAlignedDimension?

 

It has the following characteristics:

 

  1.  It is positioned halfway along the line it is dimensioning, with a perpendicular offset.
  2.  From 0° to 180° it is to the left of the line (start -> end)
  3.  From 0° to -180° it is to the right of the line (start -> end)
  4.  The offset is visually constant, independent of the current zoom state.

I can see how to calculate the position (1, 2 and 3) using a perpendicular vector that can be negated based on the angle - but how is the offset done? I assumed it would be related to DIMSCALE - but maybe has some relation to the viewport size too, in order to stay visually the same size?

 

0 Likes
767 Views
5 Replies
Replies (5)
Message 2 of 6

Kyudos
Advisor
Advisor

(I'm messing with jigs again, BTW!)

 

So some trial-and-error shows that the offset I want appears to be 50% of the dimscale value at a given zoom state.

I'm setting this when creating my dimension as it is passed to AcEdJig::dimData.

 

So my dimension replicates the default as long as I don't zoom in or out while my dimension is active. So what value should I be getting in my "dimension value update" function to keep this 'current'? It's not the DIMSCALE system variable.

0 Likes
Message 3 of 6

Kyudos
Advisor
Advisor

Further empirical evidence:

 

The dimscale value passed to AcEdJig::dimData is a constant 5.2011% of the active viewport width (and/or 14.5158% or the active viewport height).

 

I'm not so keen on "magic numbers" - can anyone see the real relationship being used here? I can use this empirically determined value to do what I want, but I rather have some understanding as to where this number comes from.

 

0 Likes
Message 4 of 6

ynapeu
Advocate
Advocate

I am not 100% sure, but i think you mean dimGap. That is the distance between dimensionline und the text.

0 Likes
Message 5 of 6

Kyudos
Advisor
Advisor

Thanks, but that's not the distance I mean.

 

This is DIMGAP:

 

Kyudos_1-1715035113868.png

 

I'm after this distance...

Kyudos_0-1715035085913.png

As above, I've determined it experimentally with some "magic numbers" which is good enough for now, but ultimately is not totally satisfactory.

0 Likes
Message 6 of 6

ynapeu
Advocate
Advocate

ok. Maybe you test with

distance = viewportheigth*(25.4)*2/3000

if you are in the metric world.

0 Likes