乐筑天下

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

[编程交流] DynamicBlockVisibilityChange。l

[复制链接]

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:08:18 | 显示全部楼层
我不确定这是否有用。这对我没有好处,所以我很乐意放弃它。
回复

使用道具 举报

2

主题

24

帖子

22

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 11:13:19 | 显示全部楼层
这条线索越来越混乱
我没说不行,那个德国人说了。
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 11:15:41 | 显示全部楼层
我知道,我只是不想打断我的帖子。
回复

使用道具 举报

20

主题

81

帖子

61

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-6 11:24:29 | 显示全部楼层
Alanjt你能把代码发出去吗?(这是一只你不能拒绝的小狗http://www.connemaraterrier.com/files/page0_4.png )
我可以用这样的剧本!!
编辑发现:
http://forums.augi.com/showthread.php?t=109054
  1. ;;; ------------------------------------------------------------------------
  2. ;;;        DynamicBlockVisibilityChange.lsp v1.0
  3. ;;;
  4. ;;;        Copyright© 10.15.09
  5. ;;;        Alan J. Thompson (alanjt)
  6. ;;;       
  7. ;;;
  8. ;;;        Permission to use, copy, modify, and distribute this software
  9. ;;;        for any purpose and without fee is hereby granted, provided
  10. ;;;        that the above copyright notice appears in all copies and
  11. ;;;        that both that copyright notice and the limited warranty and
  12. ;;;        restricted rights notice below appear in all supporting
  13. ;;;        documentation.
  14. ;;;
  15. ;;;        The following program(s) are provided "as is" and with all faults.
  16. ;;;        Alan J. Thompson DOES NOT warrant that the operation of the program(s)
  17. ;;;        will be uninterrupted and/or error free.
  18. ;;;
  19. ;;;        Allows user to select a Dynamic block and change visibility state of
  20. ;;;        all or a selection set of occurances of specified block.
  21. ;;;
  22. ;;;        Revision History:
  23. ;;;
  24. ;;; ------------------------------------------------------------------------
  25. (defun c:VC99 (/ *error* AT:ListSelect AT:TabFilter #Obj #Name #List #Vis #Choice #SS)
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. ;;; error handler
  30. (defun *error* (#Message)
  31.    (and *AcadDoc* (vla-endundomark *AcadDoc*))
  32.    (and #Message
  33.         (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
  34.         (princ (strcat "\nError: " #Message))
  35.    ) ;_ and
  36. ) ;_ defun
  37. ;list select dialog
  38. ;create a temp DCL multi-select list dialog from provided list
  39. ;value is returned in list form, DCL file is deleted when finished
  40. ;example: (setq the_list (AT:listselect "This is my list title" "Select items to make a list" "25" "30" "true" (list "object 1" "object 2" "object 3"))
  41. ;if mytitle is longer than defined width, the width will be ignored and it will fit to title string
  42. ;if mylabel is longer than defined width, mylabel will be truncated
  43. ;myheight and mywidth must be strings, not numbers
  44. ;mymultiselect must either be "true" or "false" (true for multi, false for single)
  45. ;created by: alan thompson, 9.23.08
  46. ;some coding borrowed from http://www.jefferypsanders.com (thanks for the DCL examples)
  47. (defun AT:ListSelect (mytitle ;title for dialog box
  48.                        mylabel ;label right above list box
  49.                        myheight ;height of dialog box !!*MUST BE STRING*!!
  50.                        mywidth ;width of dialog box !!*MUST BE STRING*!!
  51.                        mymultiselect ;"true" for multiselect, "false" for single select
  52.                        mylist ;list to display in list box
  53.                        / retlist readlist count item savevars fn fo valuestr dcl_id
  54.                       )
  55.    (defun saveVars (/ readlist count item)
  56.      (setq retList (list))
  57.      (setq readlist (get_tile "mylist"))
  58.      (setq count 1)
  59.      (while (setq item (read readlist))
  60.        (setq retlist (append retList (list (nth item myList))))
  61.        (while
  62.          (and
  63.            (/= " " (substr readlist count 1))
  64.            (/= "" (substr readlist count 1))
  65.          ) ;_ and
  66.           (setq count (1+ count))
  67.        ) ;_ while
  68.        (setq readlist (substr readlist count))
  69.      ) ;_ while
  70.    ) ;defun
  71.    (setq fn (vl-filename-mktemp "" "" ".dcl"))
  72.    (setq fo (open fn "w"))
  73.    (setq valuestr (strcat "value = "" mytitle "";"))
  74.    (write-line (strcat "list_select : dialog {
  75.            label = "" mytitle "";") fo)
  76.    (write-line
  77.      (strcat
  78.        "          : column {
  79.            : row {
  80.              : boxed_column {
  81.               : list_box {
  82.                  label ="" mylabel
  83.        "";
  84.                  key = "mylist";
  85.                  allow_accept = true;
  86.                  height = " myheight ";
  87.                  width = " mywidth ";
  88.                  multiple_select = " mymultiselect
  89.        ";
  90.                  fixed_width_font = false;
  91.                  value = "0";
  92.                }
  93.              }
  94.            }
  95.            : row {
  96.              : boxed_row {
  97.                : button {
  98.                  key = "accept";
  99.                  label = " Okay ";
  100.                  is_default = true;
  101.                }
  102.                : button {
  103.                  key = "cancel";
  104.                  label = " Cancel ";
  105.                  is_default = false;
  106.                  is_cancel = true;
  107.                }
  108.              }
  109.            }
  110.          }
  111. }"     ) ;_ strcat
  112. ;_ strcat
  113.      fo
  114.    ) ;_ write-line
  115.    (close fo)
  116.    (setq dcl_id (load_dialog fn))
  117.    (new_dialog "list_select" dcl_id)
  118.    (start_list "mylist" 3)
  119.    (mapcar 'add_list myList)
  120.    (end_list)
  121.    (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  122.    (action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
  123.    (start_dialog)
  124.    (if (= ddiag 1)
  125.      (setq retlist nil)
  126.    ) ;_ if
  127.    (unload_dialog dcl_id)
  128.    (vl-file-delete fn)
  129.    retlist
  130. ) ;defun
  131. ;;; Tab filter for ssget selection filtering
  132. ;;; Must use (list instead of '( to work
  133. ;;; Alan J. Thompson, 06.05.09
  134. (defun AT:TabFilter (/)
  135.    (if (eq 2 (getvar "cvport"))
  136.      (cons 410 "Model")
  137.      (cons 410 (getvar "ctab"))
  138.    ) ;_ if
  139. ) ;_ defun
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  142. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  143. (vl-load-com)
  144. (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
  145. (vla-startundomark *AcadDoc*)
  146. (cond
  147.    ((and
  148.       (setq #Obj (car (entsel "\nSelect dynamic block: ")))
  149.       (eq "INSERT" (cdr (assoc 0 (entget #Obj))))
  150.       (setq #Obj (vlax-ename->vla-object #Obj))
  151.       (eq (vla-get-isdynamicblock #Obj) :vlax-true)
  152.       (not
  153.         (vl-catch-all-error-p (setq #Name (vl-catch-all-apply 'vla-get-effectivename (list #Obj))))
  154.       ) ;_ not
  155.       (setq #List (car (vl-remove-if-not
  156.                          '(lambda (x) (eq (vla-get-PropertyName x) "Visibility"))
  157.                          (vlax-invoke #Obj 'GetDynamicBlockProperties)
  158.                        ) ;_ vl-remove-if-not
  159.                   ) ;_ car
  160.       ) ;_ setq
  161.       (setq
  162.         #List (vl-sort
  163.                 (mapcar 'vlax-variant-value
  164.                         (vlax-safearray->list (vlax-variant-value (vla-get-AllowedValues #List)))
  165.                 ) ;_ mapcar
  166.                 '<
  167.               ) ;_ vl-sort
  168.       ) ;_ setq
  169.       (setq #Vis (car (AT:ListSelect
  170.                         "Dynamic Visibilities" "Select visibility option:" "10" "5" "false" #List
  171.                        ) ;_ AT:ListSelect
  172.                  ) ;_ car
  173.       ) ;_ setq
  174.       (not (initget 0 "All Filtered"))
  175.       (or (setq #Choice (getkword "\nAll or Filtered selection [All/Filtered] <All>: "))
  176.           (setq #Choice "All")
  177.       ) ;_ or
  178.       (cond
  179.         ((eq #Choice "All")
  180.          (setq
  181.            #SS (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat #Name ",`*U*")) (AT:TabFilter)))
  182.          ) ;_ setq
  183.         )
  184.         ((eq #Choice "Filtered")
  185.          (setq
  186.            #SS (ssget ":L" (list '(0 . "INSERT") (cons 2 (strcat #Name ",`*U*")) (AT:TabFilter)))
  187.          ) ;_ setq
  188.         )
  189.       ) ;_ cond
  190.     ) ;_ and
  191.     (vlax-for x (setq #SS (vla-get-activeselectionset *AcadDoc*))
  192.       (if (eq (vl-catch-all-apply 'vla-get-effectivename (list x)) #Name)
  193.         (foreach i (vlax-invoke x 'GetDynamicBlockProperties)
  194.           (if (eq (vla-get-PropertyName i) "Visibility")
  195.             (vl-catch-all-apply 'vla-put-value (list i #Vis))
  196.           ) ;_ if
  197.         ) ;_ foreach
  198.       ) ;_ if
  199.     ) ;_ vlax-for
  200.     (vl-catch-all-apply 'vla-delete (list #SS))
  201.    )
  202. ) ;_ cond
  203. (*error* nil)
  204. (princ)
  205. ) ;_ defun

但它根本不起作用,甚至没有回错
编辑我责怪我没有填写正确的参数,autocad使可见性1而不仅仅是可见性。它现在起作用了!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 20:53 , Processed in 0.393159 second(s), 58 queries .

© 2020-2025 乐筑天下

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