有个好用的LISP看一下是不是你想要的
- (defun c:tc (/ chgtxt zoompt1 zoompt2 sstxt sstxtlen txtent1 txtins dwgscal
- pt1 pt3 num embed zoomnext txtent1 txtstyl txtlay txtinspt
- txt_elev txt_height txt_rotate txt_obliq txt_width txt_color
- txt_2_chg txt_chg)
- (setq txt (getstring T "\nEnter text string to zoom to: "))
- (initget 1 "Y N")
- (setq embed (getkword "\nSearch for embedded strings? <Y or N>: "))
- (if (= embed "Y")
- (setq txt (strcat "*" txt "*"))
- )
- (setq zoompt1 (getvar "extmin"))
- (setq zoompt2 (getvar "extmax"))
- (setq search_list
- (list
- (cons 0 "text")
- (cons 1 txt)
- )
- )
- (if (/= (setq sstxt (ssget "X" search_list)) nil)
- (progn
- (setq sstxtlen (sslength sstxt))
- (alert (strcat "\nThere are " (itoa sstxtlen) " text entities meeting your criteria"))
- (setq
- txtent1 (entget (ssname sstxt 0))
- txtins (cdr (assoc '10 txtent1))
- dwgscal (getvar "ltscale")
- pt1 (list (- (car txtins) (* 1.0 dwgscal))
- (- (cadr txtins) (* 1.0 dwgscal))
- )
- pt3 (list (+ (car txtins) (* 1.0 dwgscal))
- (+ (cadr txtins) (* 1.0 dwgscal))
- )
- )
- (command "_zoom" "w" pt1 pt3)
- (initget 1 "T P N")
- (setq chgtxt (getkword "\nEdit Text, text Properties or Neither? <T P N>: "))
- (cond ((= chgtxt "T") (command "_ddedit" (ssname sstxt 0) ""))
- ((= chgtxt "P") (txt_prop))
- ((= chgtxt "N") (setq num 1))
- )
- (setq num 1)
- (if (> sstxtlen 1)
- (progn
- (initget 1 "Y N")
- (while (and (/= (setq zoomnext (getkword "\nZoom to next string? <Y or N>: ")) "N") (< num sstxtlen))
- (ssdel (ssname sstxt 0) sstxt)
- (setq
- txtent1 (entget (ssname sstxt 0))
- txtins (cdr (assoc '10 txtent1))
- dwgscal (getvar "ltscale")
- pt1 (list (- (car txtins) (* 1.0 dwgscal))
- (- (cadr txtins) (* 1.0 dwgscal))
- )
- pt3 (list (+ (car txtins) (* 1.0 dwgscal))
- (+ (cadr txtins) (* 1.0 dwgscal))
- )
- )
- (command "_zoom" "w" pt1 pt3)
- (initget 1 "T P N")
- (setq chgtxt (getkword "\nEdit Text, text Properties or Neither? <T P N>: "))
- (cond ((= chgtxt "T") (command "_ddedit" (ssname sstxt 0) ""))
- ((= chgtxt "P") (txt_prop))
- ((= chgtxt "N") (setq num 1))
- )
- (setq num (+ num 1))
- (initget 1 "Y N")
- )
- )
- )
- (command "_zoom" zoompt1 zoompt2)
- )
- (alert (strcat "\nThe text string ,"txt", does not exist in this drawing... Sorry!!!"))
- )
- )
- (Defun txt_prop ()
- (setq
- txt_styl (cdr (assoc '7 (entget (ssname sstxt 0))))
- txt_lay (cdr (assoc '8 (entget (ssname sstxt 0))))
- txt_inspt (cdr (assoc '10 (entget (ssname sstxt 0))))
- txt_elev (cdr (assoc '38 (entget (ssname sstxt 0))))
- txt_height (cdr (assoc '40 (entget (ssname sstxt 0))))
- txt_width (cdr (assoc '41 (entget (ssname sstxt 0))))
- txt_rotate (cdr (assoc '50 (entget (ssname sstxt 0))))
- txt_obliq (cdr (assoc '51 (entget (ssname sstxt 0))))
- txt_color (cdr (assoc '62 (entget (ssname sstxt 0))))
- )
- (prompt (strcat "\nCurrent text Style is : " txt_styl))
- (prompt (strcat "\nCurrent text Layer is : " txt_lay))
- (prompt (strcat "\nCurrent text Insertion point: "
- (if (< (car txt_inspt) 0.0)
- (strcat "-" (rtos (abs (car txt_inspt)) 2 4))
- (rtos (car txt_inspt) 2 4)
- )
- ","
- (if (< (cadr txt_inspt) 0.0)
- (strcat "-" (rtos (abs (cadr txt_inspt)) 2 4))
- (rtos (cadr txt_inspt) 2 4)
- )
- ","
- (if (< (nth 2 txt_inspt) 0.0)
- (strcat "-" (rtos (abs (nth 2 txt_inspt)) 2 4))
- (rtos (nth 2 txt_inspt) 2 4)
- )
- )
- )
- (if (/= txt_elev nil)
- (prompt (strcat "\nCurrent text Elevation is : " (rtos txt_elev 2 4)))
- (prompt "\nCurrent text elevation is : 0")
- )
- (prompt (strcat "\nCurrent text Height is : " (rtos txt_height 2 4)))
- (prompt (strcat "\nCurrent text Width is : " (rtos txt_width 2 4)))
- (prompt (strcat "\nCurrent text Rotation angle is : " (rtos txt_rotate 2 4)))
- (prompt (strcat "\nCurrent text Obliquing angle is : " (rtos txt_obliq 2 4)))
- (if (/= txt_color nil)
- (prompt (strcat "\nCurrent text Color is : " (rtos txt_color 2 4)))
- (prompt "\nCurrent text color is : Bylayer")
- )
- (setq txt_2_chg 1)
- (while (/= txt_2_chg "Q")
- (initget "S L I E H W R O C Q")
- (setq txt_2_chg (getkword "\nChange which property -
- Style,Layer,Insertion point,Elev,Height,Width,Rotation,Oblique angle,Color, or Quit: "))
- (cond
- ((= txt_2_chg "S")
- (command "style" "?" "*")
- (setq txt_styl (getstring "\nWhich text style do you wish to use? : "))
- (txt_2_make)
- )
- ((= txt_2_chg "L")
- (alert "\nLook for the layer you wish")
- (command "_ddlmodes")
- (setq txt_lay (getstring "\nWhich text layer do you wish to use? : "))
- (txt_2_make)
- )
- ((= txt_2_chg "I")
- (setq txt_inspt (getpoint "\nPick new text insertion point: "))
- (txt_2_make)
- )
- ((= txt_2_chg "E")
- (setq txt_elev (getreal "\nEnter the text elevation you wish to use: "))
- (txt_2_make)
- )
- ((= txt_2_chg "H")
- (setq txt_height (getreal "\nEnter the text height you wish to use: "))
- (txt_2_make)
- )
- ((= txt_2_chg "W")
- (setq txt_width (getreal "\nEnter the text width you wish to use: "))
- (txt_2_make)
- )
- ((= txt_2_chg "R")
- (setq txt_rotate (getangle "\nEnter or pick the text rotation you wish to use: "))
- (txt_2_make)
- )
- ((= txt_2_chg "O")
- (setq txt_obliq (* (/ (getreal "\nEnter the text obliquing angle you wish to use: ") 180.0) PI))
- (txt_2_make)
- )
- ((= txt_2_chg "C")
- (setq txt_color (getreal "\nEnter the number for the text color you wish to use: "))
- (txt_2_make)
- )
- )
- )
- )
- (defun txt_2_make ()
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 7 txt_styl) (assoc 7 txt_chg) txt_chg))
- (entmod txt_chg)
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 8 txt_lay) (assoc 8 txt_chg) txt_chg))
- (entmod txt_chg)
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 10 txt_inspt) (assoc 10 txt_chg) txt_chg))
- (entmod txt_chg)
- (if (/= txt_elev nil)
- (progn
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 38 txt_elev) (assoc 38 txt_chg) txt_chg))
- (entmod txt_chg)
- )
- )
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 40 txt_height) (assoc 40 txt_chg) txt_chg))
- (entmod txt_chg)
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 41 txt_width) (assoc 41 txt_chg) txt_chg))
- (entmod txt_chg)
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 50 txt_rotate) (assoc 50 txt_chg) txt_chg))
- (entmod txt_chg)
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 51 txt_obliq) (assoc 51 txt_chg) txt_chg))
- (entmod txt_chg)
- (if (/= txt_color nil)
- (progn
- (setq txt_chg (entget (ssname sstxt 0)))
- (setq txt_chg (subst (cons 62 txt_color) (assoc 62 txt_color) txt_chg))
- (entmod txt_chg)
- )
- )
- )
|