Saturday, November 21, 2009
Home   |   Search   |   About AUGI   |   My AUGI   |   Join Now

Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP
 Welcome, Guest. 

Login

Join Now FAQ Members List Calendar Search Today's Posts Mark Forums Read

AutoLISP AutoLISP or Visual LISP, learn both here!

Reply
 
Thread Tools Display Modes
Old 2004-07-15, 06:01 PM   #1
ahipkin
Woo! Hoo! my 1st post
 
Join Date: 2003-10
Posts: 1
ahipkin is starting their journey
Default Changing text height and style in AutoLISP

Is there a way to change the height and style of text in an AutoLISP program? Currently I have to do it manually (select the text and change the height in the Properties Box). This Forum has been a wealth of information for me in the past but I haven't seen anyone mention this specifically.
ahipkin is offline   Reply With Quote
Old 2004-07-15, 06:39 PM   #2
miff
I could stop if I wanted to
 
Join Date: 2003-12
Posts: 461
miff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moonmiff has landed on the moon
Default

Yes, this is a relatively easy program to write.

Select text objects
Cycle through the selection set
Modify the "Height" and "Stylename" properties using ActiveX OR
Modify the Assoc 40 & 7 lists of the entity list with subst & entmod
Voila! you're done!

HTH,
Jeff
miff is offline   Reply With Quote
Old 2004-07-15, 08:28 PM   #3
brennan.cunningham
Member
 
Join Date: 2004-07
Posts: 4
brennan.cunningham is starting their journey
Default RE: Changing text height and style in AutoLISP

Try this out....
New text height:

Code:
(defun c:CHGHT ()
    (graphscr)
    (prompt "text height to change")(terpri)
    (setq a (ssget))
           (setq nh(getreal "New Text Height . . ? "))
           (princ "\nWORKING\n")
        (setq N (sslength a))
          (progn
          (setq n1 N)
          (repeat N
            (setq n1 (- n1 1))
            (setq b (ssname a n1))
            (setq c (cdr(assoc 0(entget b))))
            (if (= c "TEXT") (progn
                (setq e (entget b))
                (setq f (assoc 40 e))
                (setq g (atof(rtos(cdr f)2 6)))
                (entmod (subst(cons(car f) nh) f e))

            ))
            ))

(princ)
)


New text style:
(defun C:CHGSTYLE ()
   (setq e (getstring "STYLE TO CHANGE TO? >>"))(terpri)
   (setq DEG (getreal "OBLIQUING ANGLE OF NEW STYLE?>>"))(terpri)
   (setq g (dtr deg))
   (setq gh (ssget))
   (setq gi (sslength gh))                 ;number of objects selected
   (setq gk gi)
   (repeat gi
      (setq gk (- gk 1))
      (setq gr (ssname gh gk))
      (setq gt (entget gr))
      (setq gj (assoc 0 gt))
      (setq gl (cdr gj))
      (if (= gl "TEXT")
          (EDITLIST)
   )  )
(princ)
 )

(defun EDITLIST ()
            (setq b gt)
            (setq d (assoc 7 b))
            (setq d1 (cons (car d ) e))
            (setq b1 (subst d1 d b))
            (setq f (assoc 51 b1))
            (setq f1 (cons (car f ) g))
            (setq b2 (subst f1 f b1))
            (entmod b2)
)
Enjoy!

Last edited by Glenndp : 2004-07-17 at 10:41 PM. Reason: Placed routine in code tag
brennan.cunningham is offline   Reply With Quote
Old 2004-07-16, 11:31 AM   #4
David.Hoole
Active Member
 
David.Hoole's Avatar
 
Join Date: 2000-12
Location: Yorkshire
Posts: 81
David.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright future
Default

Or here's an example using Activex

Code:
(defun c:fixtext ( / ss1 index newht newstyle styledata defwidth ename txtobj)
(setq ss1 (ssget (list (cons 0 "*text")))
      index 0
      newht (getstring "\nEnter new height for text: ")
      newstyle (getstring "\Enter new style for text: ")
)
(if (setq styledata (tblsearch "style" newstyle))
    (progn
       (setq defwidth (cdr (assoc 41 styledata)))
       (while (setq ename (ssname ss1 index))
              (setq txtobj (vlax-ename->vla-object ename))
              (vlax-put-property txtobj 'Height newht)
              (vlax-put-property txtobj 'StyleName newstyle)
              (if (vlax-property-available-p txtobj 'ScaleFactor)
                  (vlax-put-property txtobj 'ScaleFactor defwidth)
              )
              (setq index (1+ index))
       )
    )
    (princ "\nRequested text style does not exist!")
)
(princ)
)
__________________
Regards,

David
David.Hoole is offline   Reply With Quote
Old 2004-07-16, 03:29 PM   #5
BCrouse
All AUGI, all the time
 
BCrouse's Avatar
 
Join Date: 2003-04
Location: Bethlehem, PA
Posts: 967
BCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moonBCrouse is reaching for the moon
Question RE: Changing text height and style in AutoLISP

Can this work for MText? If not, can it be added. Also, how would you added this to your cad?
__________________
We need men who can dream of things that never were.
John F. Kennedy (1917-1963)


Semper Fi!!!
The Motto of the United States Marine Corps. Latin for always faithful. Faithful to God, Country, Family and the Corps.
Only the Few and the Proud can Understand the meaning of Being a Marine!!!!!!!

Once a Marine, Always a Marine!!
Gulf War Veteran
Operation Restore Hope (Somalia)

USMC

Using ADT 2005
BCrouse is offline   Reply With Quote
Old 2004-07-17, 10:35 AM   #6
doggarn.70892
Member
 
Join Date: 2004-06
Location: everett, wa
Posts: 37
doggarn.70892 appears to be going the right way
Default RE: Changing text height and style in AutoLISP

Here is a niffty leroy font routine been using for years



Code:
;;TDD.LSP
;;
;;
;;Sets up text styles (IMPERIAL) without having softdesk loaded..
;;
(DEFUN C:Tdd (); Start
 
 



	(setvar "userr5" 1)
        (setvar "USERR4" (* 1 (getvar "DIMSCALE")))

(prompt "\nDefining text styles for ")


;Note this section is for model space fonts... see below for paperspace fonts
(prompt "IMPERIAL drawing..")(princ (strcat "\nCurrent Text Style set to " sname "."))
(setvar "CMDECHO" 0)
  (setvar "BLIPMODE" 0)(setq sname (getvar "textstyle"))(princ)
      (setq scl_fact (getvar "userr4"))
      (command ".style" "Standard" "simplex" (* 1.000 1.000) "1" "0" "n" "n" "n")
      (command ".style" "L10" "simplex" (* 0.010 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L20" "simplex" (* 0.020 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L30" "simplex" (* 0.030 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L40" "simplex" (* 0.040 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L50" "simplex" (* 0.050 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L60" "simplex" (* 0.060 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L80" "simplex" (* 0.080 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L100" "simplex" (* 0.100 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L120" "simplex" (* 0.120 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L140" "simplex" (* 0.140 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L175" "simplex" (* 0.175 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L200" "simplex" (* 0.200 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L240" "simplex" (* 0.240 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L290" "simplex" (* 0.290 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L350" "simplex" (* 0.350 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L425" "simplex" (* 0.425 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "L500" "simplex" (* 0.500 scl_fact) "1" "0" "n" "n" "n")
      (command ".style" "ROMANT" "ROMANT" (* 0.175 scl_fact) "1" "0" "n" "n" "n")


;Note this section is for paperspace fonts dimscale 1
      (setq scl_fact_ps (getvar "userr5"))
	
	      (command ".style" "Line" "simplex" (* 1.00 1.000) "1" "0" "n" "n" "n")
	      (command ".style" "DASH100" "dashfont" (* 0.1000 scl_fact) "1" "0" "n" "n")
	      (command ".style" "DASH120" "dashfont" (* 0.1200 scl_fact) "1" "0" "n" "n")
	      (command ".style" "DASH140" "dashfont" (* 0.1400 scl_fact) "1" "0" "n" "n")
	      (command ".style" "DASH240" "dashfont" (* 0.2400 scl_fact) "1" "0" "n" "n")
	      (command ".style" "PL100" "simplex" (* 0.1 scl_fact_PS) "1" "0" "n" "n" "n")
	      (command ".style" "PL120" "simplex" (* 0.12 scl_fact_PS) "1" "0" "n" "n" "n")
	      (command ".style" "PL140" "simplex" (* 0.14 scl_fact_PS) "1" "0" "n" "n" "n")
	      (command ".style" "PL80" "simplex" (* 0.08 scl_fact_PS) "1" "0" "n" "n" "n")
	      (command ".style" "RomanT100" "ROMANT" (* 0.1 scl_fact_PS) "1" "0" "n" "n" "n")
	      (command ".style" "RomanT120" "ROMANT" (* 0.12 scl_fact_PS) "1" "0" "n" "n" "n")     
      (setvar "cmdecho" 0)(setvar "textstyle" sname)
  
      
      (setq sname (getvar "textstyle"))
      
      (setvar "BLIPMODE" 1)(setvar "BLIPMODE" 0)
            
      
      
);end
Mike Perry
Anchorage Alaska
doggarn@acsalaska.net

Last edited by Glenndp : 2004-07-17 at 10:40 PM. Reason: Placed routine in code tag
doggarn.70892 is offline   Reply With Quote
Old 2004-07-17, 05:26 PM   #7
peter
Vice President / Director
 
peter's Avatar
 
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
peter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the starspeter is shooting for the stars
Default RE: Changing text height and style in AutoLISP

Here is a similar routine that could be used as a template to create routines that change text height style or whatever

Peter Jamtgaard

Code:
(defun C:CHW (/ inCount sngTextWidth ssSelections objSelection)
 (princ "\nSelect text entities to modify text width: ")
 (setq ssSelections (ssget (list (cons 0 "TEXT,ATTDEF")))
       sngTextWidth (getdist "\nEnter text width: ")
 )
 (if (and ssSelections
          (> sngTextWidth 0.0)
     )
  (repeat (setq intCount (sslength ssSelections))
   (setq intCount     (1- intCount)
         objSelection (vlax-ename->vla-object
                       (ssname ssSelections intCount)
                      )
   )
   (vla-put-scalefactor objSelection sngTextWidth)
  ) 
 )
 (prin1)
)
peter is online now   Reply With Quote
Old 2004-07-19, 10:13 AM   #8
David.Hoole
Active Member
 
David.Hoole's Avatar
 
Join Date: 2000-12
Location: Yorkshire
Posts: 81
David.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright futureDavid.Hoole has a bright future
Default RE: Changing text height and style in AutoLISP

The code I posted earlier will work for MTEXT, provided the formatting hasn't been applied in the MTEXT Editor. If it has there's a routine called STRIPMTEXT.LSP which will remove the formatting. It can be found at:

http://www.users.qwest.net/~sdoman/

If you're not familiar with customising AutoCAD, the easiest way to add these commands to your setup is to go to Tools>Load Application and add them to the Startup Suite.
__________________
Regards,

David
David.Hoole is offline   Reply With Quote
Reply


Go Back   AUGI Forums > AUGI Technical (English) > Programming > AutoLISP

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Styles with Height specified paul.burgener CAD Standards 5 2004-07-11 06:08 PM
Almost too basic- text style + dimension styles-setup sfickettj ACA General 9 2004-06-25 04:16 PM


All times are GMT +1. The time now is 03:47 PM.