Author Topic: mText to Single line mText?  (Read 10994 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: mText to Single line mText?
« Reply #30 on: September 29, 2014, 09:03:26 AM »
Thanks  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

hmspe

  • Bull Frog
  • Posts: 362
Re: mText to Single line mText?
« Reply #31 on: September 29, 2014, 05:57:18 PM »
I use this to get line spacing.

Code: [Select]
;;; determine line spacing for a text style
(defun enco_line_space (t_style t_height / text_style text_height dot1 dot1_entity dot2 dot2_entity spacing)
  (if (= t_style "")
    (setq text_style (getvar "textstyle"))                                                          ; get the current text style
    (setq text_style t_style)
  )
  (if (= t_height "")
    (setq text_height (getvar "textsize"))                                                          ; get the current text height
    (setq text_height t_height)
  )
  (entmake
    (list
      (cons 0 "MTEXT")                                                                              ; Entity Type
      (cons 100 "AcDbEntity")                                                                       ; 100 Entity Code
      (cons 100 "AcDbMText")                                                                        ; 100 Entity Code
      (cons 7 text_style)
      (cons 8 "0")
      (cons 40 text_height)
      (cons 1 ".")
      (cons 1 "\n.")
      (cons 10 '(0.0 0.0 0.0))                                                                      ; Insertion Point
    )
  )
  (command "explode" "last")
  (setq dot1 (entlast))                                                                             ; get the entity
  (setq dot1_entity (entget dot1))                                                                  ; get the entity's data
  (entdel dot1)                                                                                     ; get rid of the evidence
  (setq dot2 (entlast))                                                                             ; get the entity
  (setq dot2_entity (entget dot2))                                                                  ; get the entity's data
  (entdel dot2)

  (setq dot1 (caddr (assoc 10 dot1_entity)))
  (setq dot2 (caddr (assoc 10 dot2_entity)))
  (setq spacing (- (caddr (assoc 10 dot2_entity)) (caddr (assoc 10 dot1_entity))))
  spacing
)
"Science is the belief in the ignorance of experts." - Richard Feynman

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: mText to Single line mText?
« Reply #32 on: September 29, 2014, 06:04:11 PM »
I use this to get line spacing.

Code: [Select]
;;; determine line spacing for a text style
(defun enco_line_space (t_style t_height / text_style text_height dot1 dot1_entity dot2 dot2_entity spacing)
  (if (= t_style "")
    (setq text_style (getvar "textstyle"))                                                          ; get the current text style
    (setq text_style t_style)
  )
  (if (= t_height "")
    (setq text_height (getvar "textsize"))                                                          ; get the current text height
    (setq text_height t_height)
  )
  (entmake
    (list
      (cons 0 "MTEXT")                                                                              ; Entity Type
      (cons 100 "AcDbEntity")                                                                       ; 100 Entity Code
      (cons 100 "AcDbMText")                                                                        ; 100 Entity Code
      (cons 7 text_style)
      (cons 8 "0")
      (cons 40 text_height)
      (cons 1 ".")
      (cons 1 "\n.")
      (cons 10 '(0.0 0.0 0.0))                                                                      ; Insertion Point
    )
  )
  (command "explode" "last")
  (setq dot1 (entlast))                                                                             ; get the entity
  (setq dot1_entity (entget dot1))                                                                  ; get the entity's data
  (entdel dot1)                                                                                     ; get rid of the evidence
  (setq dot2 (entlast))                                                                             ; get the entity
  (setq dot2_entity (entget dot2))                                                                  ; get the entity's data
  (entdel dot2)

  (setq dot1 (caddr (assoc 10 dot1_entity)))
  (setq dot2 (caddr (assoc 10 dot2_entity)))
  (setq spacing (- (caddr (assoc 10 dot2_entity)) (caddr (assoc 10 dot1_entity))))
  spacing
)
Yes, that is what I used to use (or something very similar), but couldn't find any copies of it anywhere.