0

Needing to add some dimensions along the lower portion of a dxf created with ezdxf for clarity reasons. I used .add_aligned_dim with the points from right to left. This allowed the dimension to be placed underneath the object however, that now means the text is upside down as well. I can't find anywhere in the documentation on how to adjust the text rotation of a dimension line. Any help would be Greatly appreciated. dim5 is the dimension in question.

            # add dimension lines
        dim1 = msp.add_linear_dim(base=(9, 34), p1=(9, 33.4375), p2=(leng2 + 9 - 2.625, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim1.set_tick(size=0.25)
        dim1.render()
        dim2 = msp.add_linear_dim(base=(9, 36), p1=(9, 33.4375), p2=(leng2 + 9 - 1.125, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim2.set_tick(size=0.25)
        dim2.render()
        dim3 = msp.add_linear_dim(base=(9, 38), p1=(9, 33.4375), p2=(leng2 + 9, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim3.set_tick(size=0.25)
        dim3.render()
        dim4 = msp.add_aligned_dim(p1=(8.5, 29), p2=(8.5, 32.9375), distance=0.5,
                                   override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                   dxfattribs={"layer": "104"})
        dim4.set_tick(size=0.25)
        dim4.render()
        dim5 = msp.add_aligned_dim(p1=(10.1250, 28.5), p2=(9, 28.5), distance=0.5,
                                   override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                   dxfattribs={"layer": "104"})
        dim5.set_tick(size=0.25)
        dim5.render()

enter image description here

Rand0mdude
  • 27
  • 1
  • 10

1 Answers1

0

I was actually able to find a work around by offsetting the location I actually wanted to dimension and modifying the extensions.

            # add dimension lines
        dim1 = msp.add_linear_dim(base=(9, 34), p1=(9, 33.4375), p2=(leng2 + 9 - 2.625, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim1.set_tick(size=0.25)
        dim1.render()
        dim2 = msp.add_linear_dim(base=(9, 36), p1=(9, 33.4375), p2=(leng2 + 9 - 1.125, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim2.set_tick(size=0.25)
        dim2.render()
        dim3 = msp.add_linear_dim(base=(9, 38), p1=(9, 33.4375), p2=(leng2 + 9, 33.4375),
                                  override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                  dxfattribs={"layer": "104"})
        dim3.set_tick(size=0.25)
        dim3.render()
        dim4 = msp.add_aligned_dim(p1=(8.5, 29), p2=(8.5, 32.9375), distance=0.5,
                                   override={'dimexe': 0.25, 'dimdsep': ord('.')},
                                   dxfattribs={"layer": "104"})
        dim4.set_tick(size=0.25)
        dim4.render()
        dim5 = msp.add_aligned_dim(p1=(9, 26.0), p2=(10.1250, 26.0), distance=0.5,
                                   override={'dimexe': 2.0,
                                   'dimdsep': ord('.')}, dxfattribs={"layer": "104"})
        dim5.set_tick(size=0.25)
        dim5.set_location(location=(-2.0, 0.97), leader=True, relative=True)
        dim5.render()

enter image description here

Rand0mdude
  • 27
  • 1
  • 10
  • setting the final text rotation by dxfattribs also works: `dxfattribs={"layer": "104", "text_rotation": 0}` - the text rotation is relative to the WCS x-axis, which means 180° is upside-down and 0° is the desired upright orientation – mozman Sep 03 '22 at 03:06
  • @mozman Thanks for the tip. I guess I completely missed that attribute. – Rand0mdude Sep 06 '22 at 14:00