使用AUTOLISP增加和删除扩展实体数据
--------------------------------------------------------------------------------
;; Adding and Removing Extended Entity Data
;;***cut here to end of file, and save in a ASCII text format to file **
;;************************** XM.lsp ************************************
;; Date: April 7, 1996
;; Written for R13
;; *** Example for adding and removing extended entity data. ***
;;
;; To see how this function works, place this code fragment
;; in a file named
;; XM.LSP and place the file in a directory that is in the
;; ACAD search path
;; or in the current AutoCAD directory.
;; Start a new drawing.
;; At the AutoCAD command line type: (load "XM") <return>
;; The function will then:
;; Register the applications name.
;; Create a circle with extended entity data associated with the
;; application name.
;; Print out the assoc code list for the circle entity.
;; Remove the extended entity data from the circle.
;; Then print out the assoc list again showing the extended data
;; removed.
;;
;; AutoLISP function used in this example:
;; regapp
;; entmake
;; setq
;; assoc
;; princ
;; subst
;; entmod
;; entget
;; entlast
;;
;; See the AutoCAD Customization Guide for information
;; on using these functions
;;
;; Date: 3/7/96
;;
;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;; UNINTERRUPTED OR ERROR FREE.
;;
(regapp "FREDS")
(entmake ; makes entity
'((0 . "CIRCLE") ; entity type
(8 . "0") ; layer name
(62 . 3) ; color
(39 . 2.75) ; thickness
(10 8.0 6.0 0.0) ; center point
(40 . 2.0) ; radius
; create and add xdata
(-3 ("FREDS" (1002 . "{")
(1000 . "This is my data")
(1000 . "More Data")
(1000 . "and some more data")
(1040 . 12.345)
(1010 8.97197 6.8436 0.0)
(1040 . 2.75013)
(1002 . "}")))
)
)
(Setq a (entget (entlast) '("FREDS")))
;; gets the assoc list with attached
;; extended entity data that belongs
;; to the regapp "FREDS"
(princ a) ;; prints assoc list to screen
(princ "\n\n") ;; two blank lines
(setq z (assoc -3 a)) ;; save xdata that belongs to the
;; regapp "FREDS" to z variable
(setq a (subst'(-3 ("FREDS")) (assoc -3 a) a)) ;; new assoc list without
;; xdata. The -3 assoc code has only
;; the regapp name without any data.
;; This gets substituted for the assoc
;; -3 list that has data.
(entmod a) ;; modifies entity removing the
;; xdata because feeding a entmod
;; an assoc list with only the regapp
;; name for the -3 assoc code removes
;; the extended entity data from the
;; entity.
(Setq a (entget (entlast) '("FREDS")))
;; gets the new assoc list to verify
;; the xdata has been removed
(princ a) ;; prints the new assoc list without
;; the xdata to screen.
页:
[1]