- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've got a variety of fairly simple lisp routines for adding text to drawings. They all work fine in the WCS but not in a UCS.
I can see that there needs to be co-ordinate transformations to make them work in a UCS. This seems to involve the "TRANS" command but even after much googling I can't seem to get my head around it.
Multiple UCSs involve an initial rotation around the z axis that could be any angle, further 90 degree rotations around the z axis, and then 90 degree flips around the x axis.
I've attached three sample routines -
TT - Insert multiple lines of text equally spaced and centred at selected point.
UT - Add multiple lines of equally spaced and centred text under existing selected text.
LH - Inserts MTEXT "Loft" "hatch" at an intersection.
Hopefully someone can point me in the right direction...
(sorry the formatting is a bit messy, they came from a colleague in this state)
Thanks in advance
Quentin.
(DEFUN C:TT (/)
(GRAPHSCR)
(SETQ lll (GETVAR"CLAYER"))
(SETQ OSM (GETVAR"OSMODE"))
(COMMAND "OSNAP" "NONE")
(command "layer" "m" "GTEXT" "")
(setq edp(getpoint "TEXT AT.."))
(setq txt (getstring T "TEXT.."))
(COMMAND "TEXT" "C" EDP "" 0.0 TXt)
(setq e(entget(entlast)))
(setq en2(cdr(assoc -1 e)))
(setq en3(entget en2))
(SETQ TYPE1 (CDR (ASSOC 0 EN3)))
(textun)
(SETVAR "OSMODE" OSM)
(COMMAND "LAYER" "S" lll "")
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
(DEFUN C:UT (/)
(GRAPHSCR)
;;;EXTRACT EXISTING INFORMATION
(SETQ STYLE1 (GETVAR "TEXTSTYLE"))
(SETQ LAYER1 (GETVAR "CLAYER"))
(SETQ SIZE1 (GETVAR "TEXTSIZE"))
(SETQ COL2 (GETVAR "CECOLOR"))
(SETQ COL3 (ATOI COL2))
;;;SELECT TEXT TO UNDERWRITE
(SETQ EN1 (ENTSEL "SELECT THE TEXT TO WRITE UNDER: "))
(WHILE (= EN1 NIL)
(ALERT "NO TEXT SELECTED")
(SETQ EN1 (ENTSEL "SELECT THE TEXT TO WRITE UNDER: "))
)
(SETQ EN2 (CAR EN1))
(SETQ EN3 (ENTGET EN2))
;;;CHECK TO SEE IF TEXT OR MTEXT
(SETQ TYPE1 (CDR (ASSOC 0 EN3)))
(IF (= TYPE1 "MTEXT")(COMMAND "DDEDIT" EN1 "")(TEXTUN))
;;;RESET EXISTING VALUES
(SETVAR "TEXTSIZE" SIZE1)
(SETVAR "TEXTSTYLE" STYLE1)
(SETVAR "CLAYER" LAYER1)
(SETVAR "CECOLOR" COL2)
(PRINC)
)
(DEFUN C:LH (/)
(GRAPHSCR)
(SETQ lll (GETVAR"CLAYER"))
(SETQ OSM (GETVAR"OSMODE"))
(COMMAND "OSNAP" "INTERSECTION")
(command "layer" "m" "GTEXT" "")
(setq edp(getpoint "TEXT AT.."))
(COMMAND "MTEXT" edp "_Justify" "MC" "_none" "@" "Loft" "hatch" "")
(SETVAR "OSMODE" OSM)
(COMMAND "LAYER" "S" lll "")
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
Solved! Go to Solution.