Is There a Way to Set the Location of Dim Text w Leader?

Is There a Way to Set the Location of Dim Text w Leader?

jdrury54QED
Community Visitor Community Visitor
218 Views
1 Reply
Message 1 of 2

Is There a Way to Set the Location of Dim Text w Leader?

jdrury54QED
Community Visitor
Community Visitor

When setting up dim styles to have the text placement set to "Over dimension line, with leader" there is no setting that I'm aware of that controls where the text will be placed. Depending on the direction the dimension extension lines go (above, below, left, right, etc.) the dim text with leader seems to vary. 

 

Is there a way, with LISP to change the text placement with leader be the same distance from the dim line no matter which way the dimension goes? I hope I'm making sense.

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

SPJG
Explorer
Explorer
(defun c:adjustdimtext (/ ss idx dimobj dist)
  (setq dist 5) ; Set the desired distance from the dimension line

  ; Select dimensions in the drawing
  (setq ss (ssget '((0 . "DIMENSION"))))
  (if ss
    (progn
      (repeat (setq idx (sslength ss))
        (setq dimobj (vlax-ename->vla-object (ssname ss (setq idx (1- idx)))))
        (if (vlax-property-available-p dimobj 'TextPosition)
          (progn
            (setq textpos (vlax-get-property dimobj 'TextPosition))
            (setq dimlinepoint (vlax-get-property dimobj 'DimLinePoint))
            (setq angle (angle dimlinepoint textpos))

            ; Calculate the new position for the text
            (setq newtextpos (polar dimlinepoint angle dist))

            ; Set the new text position
            (vlax-put-property dimobj 'TextPosition newtextpos)
          )
        )
      )
      (princ "\nDimension text positions adjusted.")
    )
    (princ "\nNo dimensions found.")
  )
  (princ)
)
0 Likes