CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 8463
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedtext width lisp help

 Post Reply Post Reply
Author
marcus007 View Drop Down
Newbie
Newbie


Joined: 08.Apr.2015
Location: United States
Using: autocad
Status: Offline
Points: 8
Direct Link To This Post Topic: text width lisp help
    Posted: 05.Oct.2015 at 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)
)
mag
Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
Direct Link To This Post Posted: 05.Oct.2015 at 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?
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 631
Direct Link To This Post Posted: 05.Oct.2015 at 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))
Back to Top
marcus007 View Drop Down
Newbie
Newbie


Joined: 08.Apr.2015
Location: United States
Using: autocad
Status: Offline
Points: 8
Direct Link To This Post Posted: 06.Oct.2015 at 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
mag
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,426 seconds.