song宋_74729 发表于 2016-5-20 18:40:12

ZZXXQQ 发表于 2016-5-20 10:16 static/image/common/back.gif
(tt "PTCODE" "")

命令打TT發現錯誤

song宋_74729 发表于 2016-5-21 11:12:14

song宋_74729 发表于 2016-5-20 18:40 static/image/common/back.gif
命令打TT發現錯誤

無法刪除ptcode圖塊文字

skg123 发表于 2016-5-24 15:01:42

提问最好发图,发个附件大家还要下载,麻烦

song宋_74729 发表于 2022-8-4 12:44:18

将黄色字删除

lee50310 发表于 2022-8-5 16:47:40

本帖最后由 lee50310 于 2022-8-5 16:59 编辑



取自網路
https://autocadtips1.com/2011/04/12/autolisp-delete-attributes/


lee50310 发表于 2022-8-5 16:50:08

本帖最后由 lee50310 于 2022-8-5 17:01 编辑

執行指令:attdel
         1. 輸入圖塊名稱 99a
         2. 輸入屬性名稱 PTCODE




執行指令:attdel
         1. 輸入圖塊名稱 99
         2. 輸入屬性名稱 PTCODE

song宋_74729 发表于 2022-8-5 16:58:19

lee50310 发表于 2022-8-5 16:47
取自網路
https://autocadtips1.com/2011/04/12/autolisp-delete-attributes/

可以直接删除吗

lee50310 发表于 2022-8-5 17:04:11

本帖最后由 lee50310 于 2022-8-5 18:27 编辑

song宋_74729 发表于 2022-8-5 16:58
可以直接删除吗
當然可以,不過需要 自行修改程式

song宋_74729 发表于 2022-9-1 23:24:03

lee50310 发表于 2022-8-5 17:04
當然可以,不過需要 自行修改程式

;;
;;取自網路
;;https://autocadtips1.com/2011/04/12/autolisp-delete-attributes/
;;刪除塊中屬性
;;--------------------------------------------------------------------------------------
(vl-load-com)

(defun c:ATTDEL        (/ blkname attname bn bd en ed attlst)

(setq blkname (getstring T "\n輸入塊的名稱:ptcode "))
(if (setq bn (tblobjname "BLOCK" blkname))
      (progn
            (setq bd(entget bn)                  
                      en(cdr(assoc -2 bd))          ;;第一個實體 insie 塊
                   attlstnil                                      ;;初始化列表為空
            ) ;_ 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
;;--------------------------------------------------------------------------------------

怎么修改删除ptcode文字

lee50310 发表于 2022-9-2 04:21:48

本帖最后由 lee50310 于 2022-9-2 04:29 编辑

song宋_74729 发表于 2022-8-5 16:58
可以直接删除吗



直接刪除圖檔內99 及 99a 屬性塊的 ptcode 值

執行指令:atdel


;;--------------------------------------------------------------------------------------
(defunc: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 塊
                   attlstnil                                    ;;初始化列表為空
            ) ;_ 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
;;--------------------------------------------------------------------------------------


页: 1 [2] 3
查看完整版本: (已解决)请教高手如何将属性块内的字删除