home *** CD-ROM | disk | FTP | other *** search
- ;;;---------------------------------------------------------------------------;
- ;;;
- ;;; XDATA.LSP ¬⌐Ñ╗ 1.1
- ;;;
- ;;; (C) ¬⌐┼v 1988-1992 Autodesk ñ╜Ñq
- ;;;
- ;;; Ñ╗╡{ªíñwÑ╤ Autodesk ñ╜Ñq╡∙ÑU¬⌐┼v, ╢╚⌐≤ñU¡z▒í¬pñUÑi▒┬╗P▒zíu│\ÑiívíC
- ;;; ╗╒ñUñú▒oÑHÑ⌠ª≤º╬ªí╡oªµ⌐╬ÑX¬⌐ª╣╡{ªí¬║íu¡∞⌐l╜Xív; ª²ñ╣│\▒zªb»S⌐w¡lÑ═
- ;;; ¬║ñuº@ñW╡▓ªXª╣╡{ªí¬║íuÑ╪¬║╜Xív¿╧Ñ╬íCª│├÷│o├■¡lÑ═ñuº@¬║▒°Ñ≤ªpñU:
- ;;;
- ;;; ( i) │]¡pñW╗Pñuº@ñW¼╥»┬║Θ░w╣∩ Autodesk ñ╜Ñq¬║▓ú½~íC
- ;;; (ii) ╕ⁿª│íu¬⌐┼v (C) 1988-1992 Autodesk ñ╜Ñqív¬║¬⌐┼v│qºiíC
- ;;;
- ;;;
- ;;;
- ;;; AUTODESKñ╜Ñq┤ú¿╤ª╣╡{ªí╢╚¿╤º@íu├■ªⁿív¬║░╤ª╥, ª╙ÑBñú▒╞░úª│Ñ⌠ª≤┐∙╗~¬║
- ;;; Ñi»αíCAUTODESKñ╜Ñq»Sª╣º_╗{Ñ⌠ª≤»S⌐wÑ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºt
- ;;; ÑX¿π¬║½O├╥íCAUTODESKñ╜ÑqªP«╔ÑτñúÑX¿πª╣╡{ªí░⌡ªµ«╔ñ@⌐wñú╖|íuññ┬_ív⌐╬
- ;;; íuº╣Ñ■╡L╗~ív¬║½O├╥íC
- ;;;
- ;;;
- ;;; by Kieran V. McKeogh, Brad Zehring
- ;;; 5 March 1990
- ;;;
- ;;; Modified on March 11, 1991 by Kieran McKeogh. (xdsize) check added.
- ;;;
- ;;;---------------------------------------------------------------------------;
- ;;; DESCRIPTION
- ;;;
- ;;; XDATA
- ;;;
- ;;; Program that attaches extended data types to a selected entity.
- ;;;
- ;;; After selecting an entity and entering an application name for the
- ;;; extended data, the following types of extended data are prompted for:
- ;;;
- ;;; 1) An ASCII string up to 255 bytes long (group code 1000).
- ;;; 2) A layer name (group code 1003).
- ;;; 3) An entity handle (group code 1005).
- ;;; 4) 3 real numbers (group code 1010).
- ;;; 5) A 3D World space position (group code 1011).
- ;;; 6) A 3D World space displacement (group code 1012).
- ;;; 7) A 3D World space direction (group code 1013).
- ;;; 8) A real number (group code 1040).
- ;;; 9) A distance (group code 1041).
- ;;; 10) A scale factor (group code 1042).
- ;;; 11) A 16-bit integer (group code 1070).
- ;;; 12) A 32-bit signed long integer (group code 1071).
- ;;;
- ;;; Numbers 5, 6, 7, 9 and 10 are "transformable" data types, and
- ;;; are either moved, scaled, rotated or mirrored along with the parent
- ;;; entity, or possibly some combination of these, depending on the
- ;;; group code and the nature of the operation on the parent entity.
- ;;;
- ;;; Binary data chunks (group code 1004) are not supported.
- ;;;
- ;;;
- ;;; XDLIST
- ;;;
- ;;; Program that lists the Xdata associated with an application for the
- ;;; selected entity.
- ;;;
- ;;; For a complete description of extended data types see the "AutoCAD
- ;;; Reference Manual."
- ;;;
- ;;;---------------------------------------------------------------------------;
-
-
- ;;;---------------------------------------------------------------------------;
- ;;; Internal error handling.
- ;;;---------------------------------------------------------------------------;
-
- (defun xdataerr(s)
- (if (/= s "Function cancelled")
- (princ (strcat "\n┐∙╗~: " s))
- )
- (setq *error* olderr)
- (if ename (redraw ename 4)) ; de-highlight entity
- (princ)
- )
-
- ;;;---------------------------------------------------------------------------;
- ;;; Get user input.
- ;;;---------------------------------------------------------------------------;
-
- (defun getinput (/ cont esel)
-
- ;; Forces selection of an entity and sets ename to the name of the
- ;; selected entity.
-
- (while
- (not (setq esel (entsel)))
- )
-
- (if (= which 1) ; If XDATA() is happening...
- (progn
- (setq ename (car esel)) ; Get entity info...
- (redraw ename 3) ; ...highlight entity
- (setq elist (entget ename (list "*"))) ; ...including xdata for all
- ; registered applications.
-
- ;; Force the entry of a registered application name (group code 1001).
-
- (setq cont T)
- (while cont
- (setq rname (strcase (getstring "\níu└│Ñ╬├■╢╡ívªW║┘: ")))
- (if (/= rname "")
- (setq cont nil)
- )
- )
- )
- )
- (if (= which 2) ; If XDPRINT() is happening...
- (progn
- (setq ename (car esel)) ; Get entity info
- (redraw ename 3) ; ...highlight entity
- (setq rname (strcase (getstring "\níu└│Ñ╬├■╢╡ívªW║┘ <*>: ")))
- (if (= rname "") ; If null input, get all.
- (setq rname "*")
- )
- (setq elist (entget ename (list rname)))
- )
- )
- )
-
- ;;;---------------------------------------------------------------------------;
- ;;; Get user values for extended entity data and build XD_LIST.
- ;;;---------------------------------------------------------------------------;
-
- (defun getdata (/ xd_type)
-
- (setq xflag 0)
-
- ;; Check whether the selected entity has some extended data already.
-
- (if (assoc -3 elist)
- (progn
- (setq size_old (xdsize (assoc -3 elist)))
- (princ "\n╣╧ñ╕ª│ ")
- (princ size_old )
- (princ " byte ¬║ Xdata í╨ ╖s¬║ Xdata ▒N│QÑ[ñJíC\n")
- )
- )
-
- (setq xd_list (list '(1002 . "}"))) ; Initialize list of xdata for this app.
-
- (setq xd_type T) ; Initialize loop terminator.
-
- (while (not (or (eq xd_type "EXit") (eq xd_type "Xit") (eq xd_type nil)))
- (setq hand (getvar "handles"))
- (initget ; Initialize keyword list.
- (strcat "STring LAyer 3Real Position DISPlacement Handle"
- " DIRection Real DISTance SCale"
- " Integer LOng EXit Xit"
-
- )
- )
-
- (setq xd_type (getkword (strcat ; Prompt user to select keyword.
- "\n3R╣Ω╝╞/DIRñΦªV/DISPª∞▓╛/DIST╢Z┬≈/Hñ▐╝╨/I╛π╝╞/"
- "\nLA╣╧╝h/LO¬°╛π╝╞/Pª∞╕m/R╣Ω╝╞/SCñ±¿╥½Y╝╞/STªrªΩ/<X░hÑX>: "))
- )
-
- ;; Add sub-list to xdata list.
-
- (cond
- ((eq xd_type "3Real")
- (if (/= (setq input (getpoint "\n3 ╣Ω╝╞: ")) nil)
- (setq xd_list (cons (cons 1010 input) xd_list))
- )
- )
- ((eq xd_type "DIRection")
- (if (/= (setq input (getpoint "\n3D Ñ@¼╔¬┼╢ííuñΦªVív: ")) nil)
- (setq xd_list (cons (cons 1013 input) xd_list))
- )
- )
- ((eq xd_type "DISPlacement")
- (if (/= (setq input (getpoint "\n3D Ñ@¼╔¬┼╢ííuª∞▓╛ív: ")) nil)
- (setq xd_list (cons (cons 1012 input) xd_list))
- )
- )
- ((eq xd_type "DISTance")
- (if (/= (setq input (getdist "\n╢Z┬≈: ")) nil)
- (setq xd_list (cons (cons 1041 input) xd_list))
- )
- )
- ((eq xd_type "Handle")
- (if (or ( = (setq hand (getstring "\n╕Ω«╞«wíuñ▐╝╨ív: ")) "0")
- (handent hand)
- )
- (setq xd_list (cons (cons 1005 hand) xd_list))
- (if (/= hand "")
- (princ "\níuñ▐╝╨ív╡L«─ í╨ ñ▐╝╨Ñ▓╢╖íuªsªbív⌐╬¼░íu0ívíC")
- )
- )
- )
- ;; Values entered greater than 32767 cause AutoLISP to issue an
- ;; error message stating "Value must be between -32767 and 32767. "
- ;; Values less than 0 are trapped out by the (initget). Though the
- ;; message may be confusing, the values are always correct. This is
- ;; an AutoLISP limitation.
- ((eq xd_type "Integer")
- (initget 4)
- (if (/= (setq input (getint "\níu16-bitív╛π╝╞: ")) nil)
- (setq xd_list (cons (cons 1070 input) xd_list))
- )
- )
- ((eq xd_type "LAyer")
- (setq input (getstring "\n╝hªW: "))
- (if (tblsearch "layer" input)
- (setq xd_list (cons (cons 1003 input) xd_list))
- (if (/= input "")
- (princ "\níu╝hªWív╡L«─ í╨ ╣╧╝hÑ▓╢╖ªsªbíC")
- )
- )
- )
- ((eq xd_type "LOng")
- (if (/= (setq input (getint "\níu32-bitív▒a╕╣¬°╛π╝╞: ")) nil)
- (setq xd_list (cons (cons 1071 input) xd_list))
- )
- )
- ((eq xd_type "Position")
- (if (/= (setq input (getpoint "\n3D Ñ@¼╔¬┼╢ííuª∞╕mív: ")) nil)
- (setq xd_list (cons (cons 1011 input) xd_list))
- )
- )
- ((eq xd_type "Real")
- (if (/= (setq input (getreal "\n╣Ω╝╞: ")) nil)
- (setq xd_list (cons (cons 1040 input) xd_list))
- )
- )
- ((eq xd_type "SCale")
- (if (/= (setq input (getreal "\nñ±¿╥½Y╝╞: ")) nil)
- (setq xd_list (cons (cons 1042 input) xd_list))
- )
- )
- ((eq xd_type "STring")
- (setq xd_list (cons (cons 1000 (getstring T
- "\nASCII ªrªΩ: ")) xd_list))
- )
- (t)
- )
- )
-
- ;; Was any xdata entered besides a registered application name ??
-
- (setq xflag (length xd_list))
-
- ;; Append opening brace to front of xdata list.
-
- (setq xd_list (cons '(1002 . "{") xd_list))
-
- ;; Append application name to front of xdata list.
-
- (setq xd_list (cons rname xd_list))
-
- ;; Append -3 group code to front of list containing xdata list.
-
- (setq xd_list (list -3 xd_list))
-
- ;; Find the total size of the new xdata.
-
- (setq size_new (xdsize xd_list))
- )
-
-
- ;-----------------------------------------------------------------------------;
- ; XDATA
- ;-----------------------------------------------------------------------------;
-
- (defun c:xdata (/ all elist ename old olderr new rname size_new xd_list
- xd_list1 xd_list2 xd_list3 xd_ent regflag hand xflag
- size_old which)
-
-
-
- (setq olderr *error* ; Use special error handling function.
- *error* xdataerr)
-
- (setq which 1) ; Flag for (getinput)
-
- (setq regflag 0) ; Regapp flag.
-
- (getinput) ; Prompt for user input
-
- (redraw ename 4) ; De-highlight entity
-
-
-
- (if (regapp rname) ; Register the application name.
- (princ (strcat "\n" rname " í╨ ╖síu└│Ñ╬├■╢╡ívíC\n"))
- (princ (strcat "\n└│Ñ╬├■╢╡íu" rname "ívñw╡n░OíC\n"))
- )
-
- ;; Prompt for user values for xdata and build xdata list XD_LIST.
-
- (getdata)
-
- ;; The extended data list is now added to the entity data. This is a
- ;; little more involved if the entity already has extended data. A check
- ;; of available Xdata space must be made too.
-
- (if (< size_new (xdroom ename)) ; If there is room for more...
- (progn
- (if (assoc -3 elist) ; and contains xdata already...
- (progn
- (setq xd_list (cdr xd_list)) ; New xdata.
- (setq xd_ent (cdr (assoc -3 elist))) ; Old xdata.
- ;; Find old xdata with same regapp
- (if (setq old (cddr (assoc rname xd_ent)))
- (progn
- (setq regflag 1)
- (setq new (cdr (reverse (cddr (assoc rname xd_list)))))
- (setq all (append new old)) ; Join old and new xdata with
- ; same application name.
- (setq xd_list1 (cons (cons 1002 "{") all)) ; Add open curly
- (setq xd_list2 (cons rname xd_list1)) ; Add regapp
-
- ;; Substitute back into existing xdata list.
-
- (setq xd_list3 (subst xd_list2 (assoc rname xd_ent)
- (assoc -3 elist)))
- )
- (progn ; This is a new regapp...
- (setq xd_list (append xd_ent xd_list)) ; Joins xdata.
- (setq xd_list3 (cons -3 xd_list))
- )
- )
- (setq elist (subst xd_list3 (assoc -3 elist) elist)) ; Joins entity
- )
- (setq elist (cons xd_list elist)) ; No xdata yet.
- )
-
- )
- (princ (strcat "\n╣╧ñ╕ñ╣Ñ╬¬║íuXdata «e┐n (space)ívñú¿¼"
- " í╨ Ñ╝Ñ[ñJ╖s¬║íuXdataívíC")
- )
- )
-
- ;; Finally update the entity in the database to contain the new xdata.
-
- (if (entmod elist)
- (if (and (= 1 regflag) (<= xflag 1)) ; old application name
- (princ "\nÑ╝Ñ[ñJíuxdataívíC")
- (princ "\nÑ[ñJ╖s¬║íuxdataívíC")
- )
- )
-
- (setq *error* olderr) ; Reset the error function.
- (redraw ename 4) ; Dehighlight entity.
-
- (prin1)
- )
-
- ;;;---------------------------------------------------------------------------;
- ;;; XDLIST
- ;;;---------------------------------------------------------------------------;
-
- (defun C:XDLIST (/ linecount xd_list app_list app_sub_list xd_code
- xd_data rname elist ename)
-
- (setq olderr *error* ; Redefine error handler.
- *error* xdataerr)
-
- (setq which 2) ; Flag for (getinput)
-
- (getinput) ; Get user input.
-
- (redraw ename 4) ; De-highlight entity.
-
- ;; See if there's any xdata in the selected entity associated with the
- ;; application name.
-
- (if (not (setq xd_list (assoc -3 elist)))
- (progn
- (princ "\n¿Sª│╗Píu└│Ñ╬├■╢╡ív├÷┴p¬║íuXdataívíC")
- )
- (setq xd_list (cdr xd_list)) ; Strip -3 from xd_list
- )
-
- (setq linecount 0) ; # of lines printed
-
- (while xd_list ; There's any xdata left...
- (setq app_list (car xd_list))
- (textscr)
- (princ "\n\n* ñw╡n░O¬║íu└│Ñ╬├■╢╡ívªW║┘: ")
- (princ (car app_list))
- (setq app_list (cdr app_list)) ; Strip app name
- (while app_list
- (setq app_sub_list (car app_list)) ; Get sub list
- (setq xd_code (car app_sub_list)) ; Get group code
- (setq xd_data (cdr app_sub_list)) ; Get data
-
- ;; Conditions for all group codes.
- ;; Prints 'em all except binary chunks.
- (cond
- ((= 1000 xd_code)
- (princ "\n* ╜X 1000, ASCII ªrªΩ: ")
- (princ xd_data)
- )
- ((= 1001 xd_code)
- (princ "\n* ╜X 1001, ñw╡n░Oíu└│Ñ╬├■╢╡ívªW║┘: ")
- (princ xd_data)
- )
- ((= 1002 xd_code)
- (princ "\n* ╜X 1002,íu░_⌐lív⌐╬íu╡▓º⌠ív¼A╕╣: ")
- (princ xd_data)
- )
- ((= 1003 xd_code)
- (princ "\n* ╜X 1003, ╝hªW: ")
- (princ xd_data)
- )
- ((= 1004 xd_code)
- (princ "\n* ╜X 1004, Ñ╝ªLÑ▄¬║íuñG╢iª∞╕Ω«╞ívíC")
- )
- ((= 1005 xd_code)
- (princ "\n* ╜X 1005, ╕Ω«╞«wíuñ▐╝╨ív: ")
- (princ xd_data)
- )
- ((= 1010 xd_code)
- (princ "\n* ╜X 1010, 3 ╣Ω╝╞: ")
- (princ (strcat "("
- (rtos (car xd_data)) " "
- (rtos (cadr xd_data)) " "
- (rtos (caddr xd_data)) ")"))
- )
- ((= 1011 xd_code)
- (princ "\n* ╜X 1011, 3D Ñ@¼╔¬┼╢ííuª∞╕mív: ")
- (princ (strcat "("
- (rtos (car xd_data)) " "
- (rtos (cadr xd_data)) " "
- (rtos (caddr xd_data)) ")"))
- )
- ((= 1012 xd_code)
- (princ "\n* ╜X 1012, 3D Ñ@¼╔¬┼╢ííuª∞▓╛ív: ")
- (princ (strcat "("
- (rtos (car xd_data)) " "
- (rtos (cadr xd_data)) " "
- (rtos (caddr xd_data)) ")"))
- )
- ((= 1013 xd_code)
- (princ "\n* ╜X 1013, 3D Ñ@¼╔¬┼╢ííuñΦªVív: ")
- (princ (strcat "("
- (rtos (car xd_data)) " "
- (rtos (cadr xd_data)) " "
- (rtos (caddr xd_data)) ")"))
- )
- ((= 1040 xd_code)
- (princ "\n* ╜X 1040, ╣Ω╝╞: ")
- (princ (rtos xd_data))
- )
- ((= 1041 xd_code)
- (princ "\n* ╜X 1041, ╢Z┬≈: ")
- (princ (rtos xd_data))
- )
- ((= 1042 xd_code)
- (princ "\n* ╜X 1042, ñ±¿╥½Y╝╞: ")
- (princ (rtos xd_data))
- )
- ((= 1070 xd_code)
- (princ "\n* ╜X 1070,íu16-bitív╛π╝╞: ")
- (princ xd_data)
- )
- ((= 1071 xd_code)
- (princ "\n* ╜X 1071,íu32-bitív▒a╕╣¬°╛π╝╞: ")
- (princ (rtos xd_data 2 0))
- )
- (t
- (princ "\n* ñú⌐·¬║íuxdata ╜Xív: ")
- (princ xd_code)
- (princ " *")
- )
- )
- (setq app_list (cdr app_list))
- (setq linecount (1+ linecount))
- (if (>= linecount 20) ; Pause at 20 lines printed.
- (progn
- (getstring "\n-▒╡ñU¡╢-")
- (setq linecount 0)
- )
- )
- )
- (setq xd_list (cdr xd_list)) ; Get next xdata list.
- )
-
-
- (princ "\n\n╣╧ñ╕ª│ ")
- (princ (xdroom ename)) ; Figure how much room is left.
- (princ " bytes ñ╣Ñ╬¬║íuXdata «e┐n (space)ívíC")
-
- (setq *error* olderr) ; Reset the error function.
- (prin1) ; Quiet exit.
-
- )
- ;;;---------------------------------------------------------------------------;
- (princ "\níuC:XDATAívñw╕ⁿñJ; ╜╨┐ΘñJ XDATA ñ╬ XDLIST ¿╙⌐w╕q╗PªCÑ▄╕Ω«╞íC ")
- (princ)