After some additional investigation, I've confirmed that this is indeed related to the Dimension Type (Vertical vs Horizontal) of the marking.
Here, I select the 37mm vertical dimension, along the left hand side of the component. Note the From and To coordinates: (0, 0) and (25, 37).
With the same dimension selected, I changed the DType from Vertical to Horizontal. The dimension is redrawn for a horizontal orientation, but the From and To coordinates are the same.
Interestingly, if I then go BACK to Vertical orientation, then the orientation does go back to vertical, but the position does not return to where it should.
The variable of interest here is the Align field. This is the value that controls where the dimension is drawn.
It looks like the Align data field is not being applied properly when switching between Horizontal and Vertical modes. And, I suspect that in a layout, rotating the component 90 degrees changes the DType from Horizontal to Vertical and vice versa.
To confirm this, I took a look at the git differences to my library file before and after switching the dimension from Vertical mode to Horizontal mode:
-<dimension x1="0" y1="0" x2="25" y2="37" x3="-4" y3="18.5" textsize="1.27" layer="49" dtype="vertical"/>
+<dimension x1="0" y1="0" x2="25" y2="37" x3="12.5" y3="18.5" textsize="1.27" layer="49" dtype="horizontal"/>
It appears that switching from Vertical mode to Horizontal mode triggers the x3 field (which is the Align field) to be changed from -4 to 12.5. I suspect that behind the scenes, Eagle automatically recalculates the x3 field to be (x1 + x2)/2. This ensures that the text label is position in the middle of the dimension marking.
Back in the GUI, I have also observed that trying to manually adjust the x3 align value will not work when in Horizontal mode. The X align value is locked.
Another thing I found. If the component holding the Dimension objects is rotated, then the values of those dimensions will change based on the new orientation of the component.
Here's an example of the same component rotated 1 degree:
Note that both the X and Y dimensions do not rotate with the component - they update their value to give the new X/Y measurements between the two points marked within the component library.
In my opinion, this is highly unexpected and confusing behavior. Dimensions that are added at the component level should be drawn relative to the orientation of the component. They should be static markings, rather than dynamically updating as the component orientation changes.
So in summary:
When Dtype is set to Horizontal, the X align field is locked as (From X Value + To X Value) / 2.
When Dtype is set to Vertical, the Y align field is locked as (From
Y Value + To Y Value) / 2.
When a component is rotated, dimension objects change their values dynamically to reflect the relative X/Y distance between the points used to create the dimension object.
This means that dimensions that are placed in a component library will have their alignment and measurement values erroneously modified by Eagle if the component is placed in a different orientation in board layout.
I can see two paths forward:
- Add your dimensions at the board layout level, after you have positioned your components, as Andy aka suggested.
- Manually add your dimensions with Eagle primitives like lines and text fields, instead of using buggy Dimension objects.