|
Welcome, Guest.
|
||||||
| AutoLISP AutoLISP or Visual LISP, learn both here! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Woo! Hoo! my 1st post
Join Date: 2003-10
Posts: 1
![]() |
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.
|
|
|
|
|
|
#2 |
|
I could stop if I wanted to
Join Date: 2003-12
Posts: 461
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
|
|
#3 |
|
Member
Join Date: 2004-07
Posts: 4
![]() |
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)
)
Last edited by Glenndp : 2004-07-17 at 10:41 PM. Reason: Placed routine in code tag |
|
|
|
|
|
#4 |
|
Active Member
Join Date: 2000-12
Location: Yorkshire
Posts: 81
![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
|
|
#5 |
|
All AUGI, all the time
Join Date: 2003-04
Location: Bethlehem, PA
Posts: 967
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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
|
|
|
|
|
|
#6 |
|
Member
Join Date: 2004-06
Location: everett, wa
Posts: 37
![]() |
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
Anchorage Alaska doggarn@acsalaska.net Last edited by Glenndp : 2004-07-17 at 10:40 PM. Reason: Placed routine in code tag |
|
|
|
|
|
#7 |
|
Vice President / Director
Join Date: 2000-09
Location: Kenosha Wisconsin
Posts: 375
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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)
)
|
|
|
|
|
|
#8 |
|
Active Member
Join Date: 2000-12
Location: Yorkshire
Posts: 81
![]() ![]() ![]() ![]() ![]() ![]() |
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 |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|
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 |