乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 46|回复: 0

[编程交流] 用于动态块的gatte

[复制链接]

73

主题

261

帖子

195

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
375
发表于 2022-7-5 19:15:12 | 显示全部楼层 |阅读模式
你好
 
我正在使用gatte更新几个版面的标题栏。我已经将标题栏编辑成一个带有可调北箭头的动态块。由于将块更改为动态块,块得到了一致的名称,gatte不再工作。有办法改变Lisp程序吗?
 
  1. ;;
  2. ;;;
  3. ;;;    GATTE.LSP
  4. ;;;    Copyright © 1999 by Autodesk, Inc.
  5. ;;;
  6. ;;;    Your use of this software is governed by the terms and conditions of the
  7. ;;;    License Agreement you accepted prior to installation of this software.
  8. ;;;    Please note that pursuant to the License Agreement for this software,
  9. ;;;    "[c]opying of this computer program or its documentation except as
  10. ;;;    permitted by this License is copyright infringement under the laws of
  11. ;;;    your country.  If you copy this computer program without permission of
  12. ;;;    Autodesk, you are violating the law."
  13. ;;;
  14. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  15. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  16. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  17. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  18. ;;;    UNINTERRUPTED OR ERROR FREE.
  19. ;;;
  20. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  21. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  22. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  23. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  24. ;;;
  25. ;;;  ----------------------------------------------------------------
  26. ;modified for XXX_YYY type attributes - CAD Studio 2012, www.cadstudio.cz
  27. (Defun C:gatte ( /
  28.     N      ;selection set counter
  29.     CC     ;changed counter
  30.     BN     ;block name
  31.     TG     ;tag name
  32.     ESel   ;entity pick/name/list
  33.     EL     ;entity list
  34.     EN     ;entity name
  35.     PASS   ;loop pass flag
  36.     TAGL   ;list of valid tags for a block
  37.     TAGS   ;String of valid tags for a block
  38.     TAGT   ;Temp tag list
  39.     ;TAG    ;tag name in loop
  40.     TMP    ;temporary variable
  41.     SS1    ;selection set of insert objects
  42.     XX X   ;flag and counter
  43.     OLDCC  ;previous count of changes for update test
  44.     A      ;entity information in change loop
  45.     FL LA  ;frozen layer check variables
  46.     na b
  47.     )
  48.   (acet-error-init
  49.      (List
  50.         (List "cmdecho" 0)
  51.         T     ;flag. True means use undo for error clean up.
  52.      ) ;list
  53.   );acet-error-init
  54.   (sssetfirst nil nil)
  55.   ;;
  56.   (Setq n 0
  57.         cc 0
  58.   )
  59.   (while (null Pass)
  60.      (initget "Block _Block")
  61. ;;      (setq ESel (entsel "\nBlock name/<select block or attribute>: "))
  62.      (setq ESel (entsel "\nSelect block or attribute [block name]: "))
  63.      (cond
  64.        ((null ESel) (setq Pass 'T BN nil))
  65.        ((= (type ESel) 'LIST) ;;pick selection
  66.           (setq EL (entget (car ESel)))
  67.           (if (= (cdr (assoc 0 EL)) "INSERT")
  68.               (setq BN (cdr (assoc 2 EL))
  69.                     Pass 'T
  70.                     ESel (nentselp (cadr ESel))
  71.                     EL (entget (car Esel))
  72.                     TG (if (= (cdr (assoc 0 EL)) "ATTRIB")
  73.                            (cdr (assoc 2 EL))
  74.                            nil
  75.                        )
  76.               )
  77.               (prompt "\nSelected item not an INSERT.")
  78.           );end if
  79.        );end second conditional for picking attrib
  80.        ((and (= (type ESel) 'STR) (= ESel "Block"))
  81.           (setq BN (getstring "\nEnter block name: "))
  82.           (if (tblsearch "BLOCK" BN)
  83.              (setq Pass 'T)
  84.              (prompt "\nInvalid block name.")
  85.           )
  86.        );end third conditional
  87.      );the conditional statement ends
  88.   ) ;;end of Block Name entry.
  89.   (if BN (progn
  90.     (setq Pass nil
  91.           EN (cdr (assoc -2 (tblsearch "BLOCK" BN)))
  92.     )
  93.     (while EN
  94.        (setq EL (entget EN))
  95.        (if (= (cdr (assoc 0 EL)) "ATTDEF")
  96.           (setq TAGL (cons (cdr (assoc 2 EL)) TAGL)))
  97.        (setq EN (entnext EN))
  98.     )
  99.   )) ;;end if BN progn
  100.   (if TG (setq Pass 'T))
  101.   (if TAGL
  102.     (progn
  103.       (setq TAGS (car TAGL)
  104.             TAGT (cdr TAGL)
  105.       )
  106.       (foreach TAG TAGT
  107.         (setq TAGS (strcat TAGS " " TAG))
  108.       )
  109.     )
  110.   )
  111.   (while (and TAGS (null Pass))
  112.      (initget (strcat "Name " (acet-str-replace "_" "-" TAGS)))
  113.      (prompt (strcat "\nKnown tag names for block: " TAGS))
  114.      (setq ESel (nentsel "\nSelect attribute or type attribute name (or [Name]): "))
  115.      (if (= ESel "Name")(setq ESel (getstring " attribute name: ")))
  116.      (cond
  117.        ((= (type ESel) 'STR)
  118.           (setq ESel (strcase ESel))
  119.           (if (member ESel TAGL)
  120.             (setq Pass 'T
  121.                   TG    ESel
  122.             )
  123.             (prompt "\nInvalid attribute name.")
  124.           )
  125.        )
  126.        ((= (type ESel) 'LIST) ;;pick selection
  127.           (setq TG (cdr (assoc 2 (entget (car ESel)))))
  128.           (if TG
  129.             (setq Pass 'T)
  130.           )
  131.        )
  132.      );the conditional statement ends
  133.   ) ;;end of Attribute Name entry.
  134.   (if (and BN (null TAGL))
  135.      (setq BN (prompt "\nThe block selected has no attributes!")))
  136.   (If (And BN TG)
  137.      (Progn
  138.         (prompt (acet-str-format "\nBlock: %1   Attribute tag: %2" BN TG))
  139.         (Setq
  140.            NA (GetString T "\nEnter new text: ")
  141.            SS1 (SsGet "_X"
  142.                 (List
  143.                    (Cons 0 "INSERT")
  144.                    (Cons 2 bn)
  145.                    (Cons 66 1)
  146.                 )
  147.              )
  148.            N (If SS1 (SsLength SS1) 0)
  149.         )
  150.         (initget 0 "Yes No _Yes No")
  151.         (setq TMP
  152.           (getkword
  153.             (acet-str-format "\nNumber of inserts in drawing = %1  Process all of them? [Yes/No] <Yes>: " (itoa N))))
  154.         (if (and TMP (= TMP "No"))
  155.            (setq SS1 (ssget (list (cons 0 "INSERT")
  156.                                   (cons 2 BN)
  157.                                   (cons 66 1)))
  158.                  N (if SS1 (sslength SS1) 0)
  159.            )
  160.         )
  161.         (if (> N 0) (Princ "\nPlease wait..."))
  162.         (setq x 0)
  163.         (repeat N
  164.            (setq A (ssname SS1 x)
  165.                  B (entget A)
  166.                  la (cdr (assoc 8 B))      ;layer name from object
  167.                  fl (tblsearch "LAYER" la) ;table entry for layer
  168.                  fl (cdr (assoc 70 fl))    ;layer status flag
  169.            )
  170.            (if (/= fl 65) ;if layer not frozen
  171.               (progn
  172.                  (setq XX 1
  173.                        oldcc cc)
  174.                  (while XX
  175.                     (setq
  176.                        B (EntGet (EntNext (CDR (Assoc -1 B))))
  177.                     )
  178.                     (If (= (CDR (Assoc 0 B)) "SEQEND")
  179.                        (Setq xx Nil)
  180.                        (Progn
  181.                           (If (= (CDR (Assoc 2 b)) tg)
  182.                              (Progn
  183.                                 (Setq B (subst (Cons 1 NA) (assoc 1 B) B)
  184.                                       CC (1+ CC)
  185.                                 )
  186.                                 (EntMod B)
  187.                              ) ;progn
  188.                           ) ;if
  189.                        ) ;progn
  190.                     ) ;if
  191.                  ) ;while
  192.                  (If (/= cc oldcc) (EntUpd a))
  193.               ) ;progn
  194.            ) ;if
  195.            (Setq X (1+ X))
  196.         ) ;repeat
  197.         (If (/= 1 cc)
  198.           (princ (acet-str-format "\n%1 attributes changed." (itoa cc)))
  199.           (princ (acet-str-format "\n%1 attribute changed." (itoa cc)))
  200.         )
  201.      ) ;progn
  202.   )
  203.   (acet-error-restore)
  204.   (Princ)
  205. ) ;defun
  206. (princ)

 
 
谢谢
 
PmxCAD
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 14:00 , Processed in 0.571250 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表