Advertisement
btronic

Text edit lsp

Jun 25th, 2012
3,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; TEXTEDIT.LSP: routine to edit Text, Attributes, Attribute Definitions,
  2. ;  or associative Dimensions with a single command.
  3. ;  Written for R.12; remove all the underscores to use it with R.11.
  4. ; NOTE: will use DDIMEDIT.DCL, if present
  5. ;
  6. ;  copyright 1993 by Mark Middlebrook, Daedalus Consulting
  7. ;  prepared for AutoCAD Power Tools,  12 Sept 93
  8. ;------------------------------------------------------------------------
  9.  
  10. (defun C:TEXTEDIT (/ olderr oteval en ed etype dcl_id)
  11.  
  12.    ;error handler
  13.    (setq olderr *error*)
  14.    (defun *error* (msg)
  15.       (if (= msg "quit / exit abort")
  16.          (princ)
  17.          (princ (strcat "error: " msg))
  18.       )
  19.       (setq *error* olderr)
  20.    (princ)
  21.    )
  22.  
  23.    (initget "Last")                 ;allow Last obj. selection [requires R.12]
  24.    (setq oteval (getvar "TEXTEVAL")
  25.          en (entsel "\nSelect Text, Attribute, or Dimension text: ")
  26.    );setq
  27.    (setvar "TEXTEVAL" 1)                           ;required for DIM NEWTEXT
  28.  
  29.    (while en
  30.       (if (= en "Last") (setq en (entlast)) (setq en (car en)))
  31.       (setq ed (entget en)
  32.             etype (cdr (assoc 0 ed))
  33.       );setq
  34.  
  35.       (cond
  36.          ((or (= etype "TEXT") (= etype "ATTDEF"))    ;Text or Attribute Def.
  37.             (command "._DDEDIT" en ""))
  38.  
  39.          ((= etype "INSERT")                          ;Block Insert
  40.             (if (= 1 (cdr (assoc 66 ed)))             ; are there Attributes?
  41.                (command "._DDATTE" en)                ;  Yes.
  42.                (prompt "\nBlock has no attributes.")  ;  No.
  43.             )
  44.          )
  45.  
  46.          ((= etype "DIMENSION")                       ;Associative Dimension
  47.             (cond
  48.                ((findfile "DDIMEDIT.DCL")
  49.                   (setq dimtxtold (cdr (assoc 1 ed)))
  50.                   (setq dcl_id (load_dialog "ddimedit.dcl"))
  51.                   (if (not (new_dialog "dim_edit" dcl_id)) (exit))
  52.                   (set_tile "dim_text" dimtxtold)
  53.                   (action_tile "dim_text" "(setq dimtxtnew $value)" )
  54.                   (action_tile "accept" "(done_dialog 1)" )
  55.                   (if (equal (start_dialog) 1)
  56.                      (entmod (list (cons -1 en) (cons 1 dimtxtnew)))
  57.                   )
  58.                   (unload_dialog dcl_id)
  59.                );use dialogue
  60.  
  61.                (T (prompt "\nEnter new dimension text: ")
  62.                   (command "._DIM1" "_NEWTEXT" pause en "")
  63.                );no dialogue
  64.             );cond
  65.          );dimension entity
  66.  
  67.          (T (prompt "\nEntity is not Text, Attribute, or Dimension text."))
  68.       );cond
  69.  
  70.       (initget "Last")
  71.       (setq en (entsel "\nSelect another <Return to quit>: "))
  72.  
  73.    );while
  74.  
  75.    (setvar "TEXTEVAL" oteval)
  76.    (setq *error* olderr)
  77.    (princ)
  78. );defun
  79.  
  80. (defun C:TE () (C:TEXTEDIT))
  81. (prompt "\nTEXTEDIT.LSP loaded.  TEXTEDIT or TE runs it.")
  82. (princ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement