MTEXT paragraph spacing change

MTEXT paragraph spacing change

james_moore
Advocate Advocate
1,107 Views
2 Replies
Message 1 of 3

MTEXT paragraph spacing change

james_moore
Advocate
Advocate

Thinking caps on...
I'm looking for a way to change MTEXT paragraph spacing within LISP or script.  The properties dialog is great, but useless to me for this task.

I've been plotting/making PDFs for years using script-based plotting, with LISP making decisions based on drawing conditions.  I have code in place to change all fonts to true-type on the fly for the styles we use.  Now I would like to update that process to duplicate whatever the Publish (or AEPublish) command does when I check the option for substituting true-type fonts for shx fonts, because it's not quite the same.

AEPublish is substituting Simplex_IV50.TTF in such a way as to maintain the existing spacing between lines.  When I change my style to use Simplex_IV50 though, the paragraph spacing is forcing the MTEXT to grow longer.

I would like to know if someone has a method for applying TSPACEFAC and TSPACETYPE variables to existing MTEXT without restoring to manually selecting every item and applying settings using the Properties dialog.  I have an idea how I can do this, but I would rather not write it if it's out there somewhere.

0 Likes
Accepted solutions (1)
1,108 Views
2 Replies
Replies (2)
Message 2 of 3

Jason.Piercey
Advisor
Advisor
Accepted solution

Quickie lisp solution.

(defun adjustMtext ( / ss i object)
  (if (setq ss (ssget "x" '((0 . "MTEXT"))))
    (progn
      (setq i 0)
      (repeat (sslength ss)
	(setq object (vlax-ename->vla-object (ssname ss i)))
	(vla-put-linespacingfactor object 1.0)
	(vla-put-lineSpacingdistance object 0.15625)
	(setq i (1+ i))
	)
      )
    )
  )

 

0 Likes
Message 3 of 3

james_moore
Advocate
Advocate

Thank you!  Much more elegant, reliable, and probably faster than my more old-school approach, which will skip some MTEXT...

 

(setq ALLOFEM (ssget "X" '((0 . "MTEXT"))))
(setq COUNT 0)
(repeat (sslength ALLOFEM)
(setq LOOKAT1 (ssname ALLOFEM COUNT))
(setq BLB (assoc 3 (entget LOOKAT1)))
(setq BLA (substr (cdr (assoc 3 (entget (ssname ALLOFEM COUNT)))) 1 4))
(if (eq bla "\\pxt")
(progn
(setq bla (substr (cdr (assoc 3 (entget (ssname ALLOFEM COUNT)))) 4))
(setq bla (strcat "\\pxsm0.963," bla))
(setq bla (CONS 3 bla))
)
)
(setq BLAH (subst BLA BLB (entget LOOKAT1)))
(entmod BLAH)
(entupd (cdr (assoc -1 BLAH)))
(setq COUNT (1+ COUNT))
)