Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mask linetype text?

1 REPLY 1
Reply
Message 1 of 2
LAURA
1040 Views, 1 Reply

Mask linetype text?

Has anyone come up with a way to do this? I use linetypes with text set above the line for water system mapping and we'd like to see how it looks masked, but don't know how to do it. I'm including the file of my linetypes.
1 REPLY 1
Message 2 of 2
DavidBethel
in reply to: LAURA

Laura,

I was hoping someone else would jump. Oh well.

Here's a routine that we have used for a long time.

It creates a block that simulates text line types with masking. It is based on our office standards with masked entities at elevation 240. Hope this helps. -David

http://64.83.21.33/lisp/ticktext.htm

;=======================================================================
; TickText.Lsp Apr 22, 2001
; Masked LineType With TEXT at Elev 240.0
;================== Start Program ======================================

(princ "\nCopyright (C) 2001, Fabricated Designs, Inc.")
(princ "\nLoading TickText v3.2 ")
(setq tt_ nil lsp_file "TickText")

;================== Macros =============================================
(defun PDot ()(princ "."))

(PDot);++++++++++++ Set Modes & Error ++++++++++++++++++++++++++++++++++
(defun tt_smd ()
(SetUndo)
(setq olderr *error*
*error* (lambda (e)
(while (> (getvar "CMDACTIVE") 0)
(command))
(and (/= e "quit / exit abort")
(princ (strcat "\nError: *** " e " *** ")))
(command "_.UNDO" "_END" "_.U")
(tt_rmd))
tt_var '(("CMDECHO" . 0) ("MENUECHO" . 0)
("MENUCTL" . 0) ("MACROTRACE" . 0)
("OSMODE" . 0) ("SORTENTS" . 119)
("MODEMACRO" . ".")
("BLIPMODE" . 1) ("SNAPMODE" . 1)
("ORTHOMODE" . 1) ("GRIDMODE" . 0)
("THICKNESS" . 0) ("ELEVATION" . 240)
("UCSICON" . 1) ("HIGHLIGHT" . 1)
("REGENMODE" . 1) ("COORDS" . 2)
("DRAGMODE" . 2) ("PDMODE" . 0)
("CECOLOR" . "BYLAYER")
("CELTYPE" . "BYLAYER")))
(foreach v tt_var
(setq m_v (cons (getvar (car v)) m_v)
m_n (cons (car v) m_n))
(setvar (car v) (cdr v)))
(princ (strcat (getvar "PLATFORM") " Release " (ver)
" - Draw Masked Text Line ....\n"))
(princ))

(PDot);++++++++++++ Return Modes & Error +++++++++++++++++++++++++++++++
(defun tt_rmd ()
(setq *error* olderr)
(mapcar 'setvar m_n m_v)
(command "_.UNDO" "_END")
(prin1))

(PDot);++++++++++++ Set And Start An Undo Group ++++++++++++++++++++++++
(defun SetUndo ()
(and (zerop (getvar "UNDOCTL"))
(command "_.UNDO" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 2) 2)
(command "_.UNDO" "_CONTROL" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 😎 😎
(command "_.UNDO" "_END"))
(command "_.UNDO" "_GROUP"))

(PDot);++++++++++++ Make A World Insert Block ++++++++++++++++++++++++++
(defun tt_tblock (fe / tt_set)
(setq bn "TEMP1" bc 1)
(while (tblsearch "BLOCK" bn)
(setq bc (1+ bc) bn (strcat "TEMP" (itoa bc))))
(setq tt_set (ssadd))
(while fe
(if (not (eq fe tt_fe))
(ssadd fe tt_set))
(setq fe (entnext fe)))
(entdel tt_fe)
(setvar "CECOLOR" "BYLAYER")
(setvar "CELTYPE" "CONTINUOUS")
(setvar "THICKNESS" 0.0)
(command "_.UCS" "_World"
"_.BLOCK" bn '(0 0 0) tt_set ""))

(PDot);++++++++++++ Origin Insert ++++++++++++++++++++++++++++++++++++++
(defun tt_osert (b)
(entmake (list (cons 0 "INSERT")(cons 8 (getvar "CLAYER"))
(cons 2 b)(cons 10 (list 0 0 0))
(cons 62 256)(cons 39 0)(cons 6 "BYLAYER")
(cons 210 (list 0 0 1)))))

(PDot);++++++++++++ Convert To Anonymous Blocks ++++++++++++++++++++++++
(defun anon (b / tdef en ed bn bd in)
(and (= (type b) 'ENAME)
(setq bd (entget b)
in (cdr (assoc 2 bd))))
(if (or (not bd)
(not in)
(/= "INSERT" (cdr (assoc 0 bd)))
(= "*" (substr in 1 1))
(= (logand (cdr (assoc 70 (tblsearch "BLOCK" in))) 4) 4)
(= (logand (cdr (assoc 70 (tblsearch "BLOCK" in))) 16) 16)
(= (logand (cdr (assoc 70 (tblsearch "BLOCK" in))) 32) 32))
(progn
(princ "*** Not A Changeable Block *** ")
(setq bd nil in nil b nil)
(exit)))
(setq tdef (tblsearch "BLOCK" in)
en (cdr (assoc -2 tdef))
ed (entget en))
(entmake (list (cons 0 "BLOCK")
(cons 2 "*U")
(cons 70 1)
(cons 10 (cdr (assoc 10 tdef)))))
(entmake ed)
(while (setq en (entnext en))
(setq ed (entget en))
(entmake ed))
(setq bn (entmake (list (cons 0 "ENDBLK"))))
(setq bd (subst (cons 2 bn) (assoc 2 bd) bd))
(entmod bd)
(entupd b))

(PDot);++++++++++++ Construct Tickline +++++++++++++++++++++++++++++++++
(defun tt_con (plist / tmp_fe tlist old_fe trd)

;;;MAKE TRACES
(command "_.POINT" '(0 0))
(setq tt_fe (entlast))
(setq plist (reverse plist))
(setq tlist plist)
(command "_.TRACE" (* 1.5 (getvar "TEXTSIZE" )) (car tlist))
(setq tlist (cdr tlist))
(foreach v tlist
(command v))
(command "")

;;;CONVERT TRACES TO INVISABLE FACES
(setq tmp_fe tt_fe)
(while tmp_fe
(setq trd (entget tmp_fe))
(if (= "TRACE" (cdr (assoc 0 trd)))
(entmake (list (cons 0 "3DFACE")
(cons 6 "BYLAYER")
(cons 10 (cdr (assoc 10 trd)))
(cons 11 (cdr (assoc 11 trd)))
(cons 12 (cdr (assoc 13 trd)))
(cons 13 (cdr (assoc 12 trd)))
(cons 39 0.0)
(cons 62 12)
(cons 70 15))))
(setq old_fe tmp_fe
tmp_fe (entnext tmp_fe))
(if (= "TRACE" (cdr (assoc 0 trd)))
(entdel old_fe)))

;;;MAKE LINES & TEXT
(while (> (length plist) 1)
(tt_text (car plist) (cadr plist))
(setq plist (cdr plist)))

;;;MAKE BLOCK
(tt_tblock tt_fe)

;;;INSERT THE BLOCK
(tt_osert bn)

;;;MAKE BLOCK ANONYMOUS
(anon (entlast))

;;;CLEAN UP
(redraw))

(PDot);++++++++++++ Get User Input +++++++++++++++++++++++++++++++++++++
(defun tt_get ()

;;;GET TEXT SIZE
(initget 6)
(setq tz (getdist (strcat "\nText Size <" (rtos (getvar "TEXTSIZE")) ">: ")))
(and (not tz)
(setq tz (getvar "TEXTSIZE")))
(setvar "TEXTSIZE" tz)

;;;GET LINE PATH
(initget 1)
(setq sp (getpoint "\nStart Point: "))
(setq plist (cons (list (car sp) (cadr sp) (getvar "ELEVATION")) plist))
(initget 1)
(setq ep (getpoint sp "\nNext Point: "))
(setq ep (list (car ep) (cadr ep) (getvar "ELEVATION")))
(while ep
(grdraw sp ep 2 1)
(setq sp ep)
(setq plist (cons (list (car ep) (cadr ep) (getvar "ELEVATION")) plist))
(setq ep (getpoint sp "\nEnd Point: "))
(and ep
(setq ep (list (car ep) (cadr ep) (getvar "ELEVATION")))))

;;;GET TEXT STRING
(if (not tx)
(progn
(initget 1)
(setq tx (getstring T "\nLine Text: "))))

;;;GET TEXT SPACING
(if (not spc)
(progn
(while (or (not spc)
(> (+ (* tz 2) (* tz (strlen tx))) spc))
(initget 7)
(setq spc (getdist "\nText Spacing ( Min Text STR Length + 2 😞 "))))))

(PDot);++++++++++++ Draw Text & Line Entities ++++++++++++++++++++++++++
(defun tt_text (fp ep / qty tsp ftd txz lnl mlp)

(setq qty (1+ (fix (/ (distance fp ep) spc)))
tsp (/ (distance fp ep) qty)
ftd (/ (distance fp ep) (* qty 2))
txz (* tz (strlen tx))
lnl (- tsp txz (* tz 2))
mlp fp)

;;;DRAW THE LINES
(if (> (distance fp ep) (+ txz (* 2 tz)))
(progn
(entmake (list (cons 0 "LINE")
(cons 62 lc)
(cons 10 mlp)
(cons 11 (polar mlp (angle fp ep) (- ftd (* txz 0.5) tz)))))

(setq mlp (polar mlp (angle fp ep) tsp))

(repeat (1- qty)
(entmake (list (cons 0 "LINE")
(cons 62 lc)
(cons 10 (polar mlp (angle ep fp) (* lnl 0.5)))
(cons 11 (polar mlp (angle fp ep) (* lnl 0.5)))))

(setq mlp (polar mlp (angle fp ep) tsp)))

(entmake (list (cons 0 "LINE")
(cons 62 lc)
(cons 10 (polar mlp (angle ep fp) (* lnl 0.5)))
(cons 11 ep)))

;;;CREATE THE TEXT
(repeat qty
(entmake (list (cons 0 "TEXT")
(cons 1 tx)
(cons 40 tz)
(cons 7 (getvar "TEXTSTYLE"))
(cons 10 (polar fp (angle fp ep) ftd))
(cons 11 (polar fp (angle fp ep) ftd))
(cons 50 (if (equal (angle fp ep) pi (* pi 0.5))
(angle ep fp)
(angle fp ep)))
(cons 51 (cdr (assoc 50 (tblsearch "STYLE" (getvar "TEXTSTYLE")))))
(cons 72 4)
(cons 62 tc)))
(setq ftd (+ ftd (/ (distance fp ep) qty)))))

(entmake (list (cons 0 "LINE")
(cons 62 lc)
(cons 10 fp)
(cons 11 ep)))))

(PDot);************ Main Program ***************************************
(defun tt_ (/ m_v m_n olderr tt_var plist sp ep bn bc
lc tc tx tz spc tt_fe)
(tt_smd)

;;;TEXT & LINE COLORS
(setq tc 3
lc 256)

(tt_get)
(tt_con plist)

(tt_rmd))

(PDot);************ Load Program ***************************************
(defun C:TickText () (tt_))
(if tt_ (princ "\nTickText Loaded\n"))
(prin1)
;================== End Program ========================================
;AS IS - NO WARRANTY

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost