本帖最后由 lee50310 于 2022-9-2 04:29 编辑
直接刪除圖檔內 99 及 99a 屬性塊的 ptcode 值
執行指令:atdel
- ;;--------------------------------------------------------------------------------------
- (defun c:atdel()
- (setq lst '("99" "99a") attname "ptcode")
- (foreach x lst (att_del x attname))
- )
- (princ "\n 刪除 99及99a 屬性塊之屬性值. 執行指令:atdel ")
- ;;--------------------------------------------------------------------------------------
- (defun att_del(blkname attname / blkname attname bn bd en ed attlst)
- (vl-load-com)
- ;; (setq blkname (getstring T "\n輸入塊的名稱:ptcode "))
- (if (setq bn (tblobjname "BLOCK" blkname))
- (progn
- (setq bd (entget bn)
- en (cdr(assoc -2 bd)) ;;第一個實體 insie 塊
- attlst nil ;;初始化列表為空
- ) ;_ end of setq
- (while en
- (setq ed (entget en))
- (if (= "ATTDEF" (cdr(assoc 0 ed))) ;; 檢查實體是否是屬性定義
- (setq attlst(cons (cons (strcase (cdr (assoc 2 ed))) ;; 添加到屬性列表
- (vlax-ename->vla-object en)
- )
- attlst
- )
- )
- ) ;_ end of if
- (setq en (entnext en)) ;;獲取下一個實體
- ) ;_ end of while
- ;; (setq attname (getstring T "\n輸入屬性標籤名稱: ptcode"))
- (if (setq en (assoc (strcase attname) attlst)) ;; 檢查屬性是否存在
- (progn
- (setq ed (cdr en)) ;;獲取屬性的VLA對象
- (vla-Delete ed)
- (princ "\n已成功從塊定義中刪除屬性。" )
- (command "_.ATTSYNC" "_Name" blkname)
- ) ;_ end of progn
- (princ "\n此圖形中不存在該屬性。 退出...")
- ) ;_ end of if
- ) ;_ end of progn
- (princ "\n此圖形中不存在該塊。 退出..." )
- ) ;_ end of if
- (princ)
- ) ;_ end of defun
- ;;--------------------------------------------------------------------------------------
|