这会将文本放入图形中:
- (defun c:lenwid (/ ent pt nlist d1 d2 len)
- (defun makelay (x)
- (if (not (tblsearch "Layer" x))
- (progn
- (setvar "cmdecho" 0)
- (command "-layer" "m" x "")
- (setvar "cmdecho" 1)
- ) ;_ end progn
- ) ;_ end if
- ) ;_ end defun
- (makelay "TEXT")
- (defun Make_Text (txt_pt txt_val)
- (entmake
- (list '(0 . "TEXT")
- '(8 . "TEXT")
- (cons 10 txt_pt)
- (cons 40 (max 2.5 (getvar "TEXTSIZE")))
- (cons 1 txt_val)
- '(50 . 0.0)
- '(7 . "STANDARD")
- '(71 . 0)
- '(72 . 1)
- '(73 . 2)
- (cons 11 txt_pt)
- ) ; end list
- ) ; end entmake
- ) ;_ end defun
- (if (and
- (setq ent (car (entsel "\nSelect Object > ")))
- (= "LWPOLYLINE" (cdr (assoc 0 (entget ent))))
- (setq pt (getpoint "\nSelect Point for Text > "))
- ) ;_ end and
- (progn
- (foreach x (entget ent)
- (if (eq 10 (car x))
- (setq nlist (cons (cdr x) nlist))
- ) ;_ end if
- ) ;_ end foreach
- (setq nlist (reverse nlist))
- (setq d1 (distance (nth 0 nlist)
- (nth 1 nlist)
- ) ;_ end distance
- d2 (distance (nth 1 nlist)
- (nth 2 nlist)
- ) ;_ end distance
- ) ;_ end setq
- (if (> d1 d2)
- (setq len (strcat "Length of Room = "
- (rtos d1 2 2)
- ", Width of Room = "
- (rtos d2 2 2)
- ) ;_ end strcat
- ) ;_ end setq
- (setq len (strcat "Length of Room = "
- (rtos d2 2 2)
- ", Width of Room = "
- (rtos d1 2 2)
- ) ;_ end strcat
- ) ;_ end setq
- ) ;_ end if
- (Make_Text pt len)
- ) ;_ end progn
- (princ "\n<!> No Object Selected or Object is not Polyline! <!>")
- ) ;_ end if
- (princ)
- ) ;_ end defun
|