Display full version of the post: text width lisp help

marcus007
05.10.2015, 03:38
ok so the deal is i handle a lot of third party drawings, i convert the drawings to my layers, text styles, text heights and text widths. I have tweaked the following lisp program i found online to convert text and mtext to my layer "htext", my textstyle "htext" and set the text height to 0.15625 multiplied by the current ltscale. the problem is with text width, my text style "htext" width is set to 1.0, i know that when you change an existing text's text style that piece of text takes on all the properties of the style. but in this program it only changes mtext width and not old fashioned single dtext. can you help a brother out?(defun c:c2Htext (/ textstyle layer selectionset integer selectionsetname obj)  (setq sc (getvar "ltscale"))  (setq newht (* sc 0.15625))  (vl-load-com)  (if (tblsearch "style" "Romand")    (setq textstyle t)    (princ "\n Text Style <Romand> is not existed ")  )  (if (tblsearch "LAYER" "Htext")    (setq layer t)    (princ "\n Layer <Htext> is not existed ")  )  (if (setq selectionset (ssget "_:L" '((0 . "TEXT,MTEXT"))))    (repeat (setq integer (sslength selectionset))      (setq selectionsetname             (ssname selectionset                     (setq integer (1- integer))             )      )      (setq obj (vlax-ename->vla-object selectionsetname))      (vla-put-height obj newht)      (vla-put-color obj 256)      (if textstyle        (vla-put-stylename obj "Romand")      )      (if layer        (vla-put-layer obj "Htext")      )    )    (princ)  )  (princ))

John Connor
05.10.2015, 11:55
So you are getting a lot of third-party drawings where the author has purposely changed the text width?  I think I can count on one finger the number of times I've run into something like that.  I think the vast majority of CAD techs accept the default of 1.0 for text width.  Is this really such a problem that it needs to be addressed in a lisp routine?

Kent Cooper
05.10.2015, 19:00
Anywhere in that (repeat) function after the (setq obj ...), put this in, to override the width factor [called the ScaleFactor VLA Property] of plain Text objects only:(if (= (vla-get-ObjectName obj) "AcDbText") (vla-put-ScaleFactor obj 1.0))

marcus007
06.10.2015, 05:28
in reply to john, it does happen from time to time and since i am putting in the effort i might as well get it perfect and thx to kent it is perfect.thx kent