乐筑天下

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

[编程交流] 从DCL cal使用entsel

[复制链接]

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 18:18:29 | 显示全部楼层 |阅读模式
***警告:如果代码按原样运行,则如果选中“拾取图元”或“拾取图层”按钮,它将锁定AutoCAD***
 
我在转换以前的select\u项目时遇到问题。lsp使用DCL接口运行。
在使用initget/cond显示菜单之前,它运行良好。
 
lisp中的错误行是:
  1. ((= optn 1)
  2.              (done_dialog)
  3.             (setq ent (car (entsel))
  4.                   filt (list (assoc 0 (entget ent)))
  5.                   itm (cdr(assoc 0 (entget ent))))
  6.             (cond
  7.                     (= itm "ATTDEF") (setq itm "ATTRIBUTE")
  8.                     (= itm "INSERT") (setq itm "BLOCK")
  9.                     (= itm "MLINE") (setq itm "MULTILINE")
  10.                     (= itm "LWPOLYLINE") (setq itm "POLYLINE")
  11.         (= itm "XLINE") (setq itm "CONSTRUCTION LINE")
  12. )
  13. (setq txt (strcat itm " Entity(s)"))
  14.     )

 
以及:
  1. ((= optn 51)
  2.              (done_dialog)      
  3.             (setq ent (car (entsel))       
  4.                   filt (list (assoc 8 (entget ent)))
  5.                   itm (cdr(assoc 8 (entget ent)))
  6.       txt (strcat "Layer " itm " items"))
  7. )

如果选择了其他选项,DCL和lisp工作正常。
 
 
它应该:
1)退出DCL对话
2) 执行ensel以获取实体
3) 为varios设置一些变量
4) 然后退出cond转到ssget
 
但是,当代码试图在后台执行entsel时,对话框被锁定。
 
***警告:如果代码按原样运行,则如果选中“拾取图元”或“拾取图层”按钮,它将锁定AutoCAD***
选择_项。lsp
选择_项。DCL
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:28:22 | 显示全部楼层
快速浏览一下,在action\u互动程序中执行done\u对话框部分,例如(action\u互动程序“56”“(done\u dialog 56”))并使用(setq optn(start\u dialog)),然后检查对话框返回值(optn)
 
 
gr.Rlx
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:39:22 | 显示全部楼层
  1. (defun c:Select_Items ( / dcl_id *error* ent filt itm optn ss txt )
  2.    (defun *error* ( msg )
  3.        (princ "error: ")
  4.        (princ msg)
  5.        (princ)
  6.    )
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. (defun doButton (optn)
  9.   (cond
  10.     ((= optn 1)
  11.       (done_dialog)
  12.      (setq ent (car (entsel))
  13.            filt (list (assoc 0 (entget ent)))
  14.            itm (cdr(assoc 0 (entget ent))))
  15.      (cond
  16.       (= itm "ATTDEF") (setq itm "ATTRIBUTE")
  17.       (= itm "INSERT") (setq itm "BLOCK")
  18.       (= itm "MLINE") (setq itm "MULTILINE")
  19.       (= itm "LWPOLYLINE") (setq itm "POLYLINE")
  20. (= itm "XLINE") (setq itm "CONSTRUCTION LINE")
  21. )
  22. (setq txt (strcat itm " Entity(s)"))
  23.     )
  24. ((= optn 2)
  25.      (setq filt '((0 . "ATTDEF"))
  26.       txt "ATTRIBUTE Entity(s)")
  27.       (done_dialog)
  28.     )
  29.     ((= optn 3)
  30.      (setq filt '((0 . "INSERT"))
  31.       txt "BLOCK Entity(s)")
  32.       (done_dialog)      
  33.     )
  34.     ((= optn 4)
  35.      (setq filt '((0 . "LINE"))
  36.       txt "LINE Entity(s)")
  37.       (done_dialog)      
  38.      )
  39.    
  40.     ((= optn 5)
  41.      (setq filt '((0 . "LWPOLYLINE"))
  42.       txt "POLYLINE Entity(s)")
  43.       (done_dialog)      
  44.      )
  45.    
  46.     ((= optn 6)
  47.      (setq filt '((0 . "*TEXT"))
  48.       txt "TEXT and/or MTEXT Entity(s)")
  49.       (done_dialog)      
  50.      )
  51.     ((= optn 51)
  52.       (done_dialog)      
  53.      (setq ent (car (entsel))
  54.            filt (list (assoc 8 (entget ent)))
  55.            itm (cdr(assoc 8 (entget ent)))
  56.       txt (strcat "Layer " itm " items"))
  57. )
  58.     ((= optn 52)
  59.      (setq filt '((8 . "DIMENSIONS"))
  60.            txt "items on layer DIMENSIONS")
  61.       (done_dialog)
  62.     )
  63.    
  64.     ((= optn 53)
  65.   (setq filt '((8 . "NO PRINT"))
  66.            txt "items on layer NO PRINT")
  67.       (done_dialog)      
  68.     )
  69.     ((= optn 54)
  70.      (setq filt '((8 . "PCAB"))
  71.            txt "items on layer PCAB")
  72.       (done_dialog)      
  73.     )         
  74.    
  75.     ((= optn 55)
  76.   (setq filt '((8 . "SCREEN"))
  77.            txt "items on layer SCREEN")
  78.       (done_dialog)      
  79.     )
  80.    
  81.     ((= optn 56)
  82. (setq filt '((8 . "TEXT"))
  83.            txt "items on layer TEXT")
  84.       (done_dialog)      
  85.     )
  86.    
  87.   );; end cond
  88. );; end (defun doButton (optn)
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90.   (if(not(setq dcl_id (load_dialog (findfile "Select_Items.dcl"))))   ;;;--- Load the dcl file from disk into memory
  91.    (progn ;; progn1
  92.      (alert "The DCL file could not be loaded.")
  93.      (exit)
  94.    );; end progn1
  95.    ;;;--- Else, the file was loaded
  96.    (progn;; progn2
  97.       ;;;--- Load the dialog definition inside the DCL file
  98.       (if (not (new_dialog "Select_Items" dcl_id))
  99.        (progn
  100.         (alert "The Select_Items definition could not be found in the DCL file!")
  101.          (exit)
  102.        )
  103.        ;;;--- Else, the definition was loaded
  104.        (progn ;; progn3
  105.          ;;;--- If an action event occurs, do this function
  106.           (action_tile "1" "(done_dialog 1)")
  107.           (action_tile "2" "(done_dialog 2)")
  108.           (action_tile "3" "(done_dialog 3)")
  109.           (action_tile "4" "(done_dialog 4)")
  110.           (action_tile "5" "(done_dialog 5)")
  111.           (action_tile "6" "(done_dialog 6)")
  112.   
  113.           (action_tile "51" "(done_dialog 51)")
  114.           (action_tile "52" "(done_dialog 52)")
  115.           (action_tile "53" "(done_dialog 53)")
  116.           (action_tile "54" "(done_dialog 54)")
  117.           (action_tile "55" "(done_dialog 55)")
  118.           (action_tile "56" "(done_dialog 56)")
  119.           (action_tile "cancel" "(done_dialog 0)")
  120.           (setq optn (start_dialog))  ;;;--- Display the dialog box
  121.           (unload_dialog dcl_id) ;;;--- Unload the dialog box
  122.   (if (> optn 0)(doButton optn))
  123.        );; end progn3
  124.      );; end (not (new_dialog "Select_Items" dcl_id))
  125.    );; end progn2
  126. );; end    (if(not(setq dcl_id (load_dialog "Select_Items.dcl")))  
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. (if filt
  129. (progn;; then
  130. (sssetfirst nil (setq ss (ssget "_:L" filt)))
  131.   (if ss
  132.     (princ (strcat "\n "(itoa (sslength ss)) " "txt" Selected"))
  133.     (princ "\n Nothing Found")
  134.   )
  135.   );end progn/then
  136.   (princ "\nSelect Items Lisp Cancelled");; else
  137. );; end (if (= stop nil)
  138. (princ)
  139. )

没有做任何进一步的检查。。。但是你可以/必须从你的doButton函数中删除所有done\u对话框,因为这现在是由你的动作块处理的(贴在quick上)
 
 
gr.Rlx
回复

使用道具 举报

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 18:45:56 | 显示全部楼层
Soopurb,谢谢Rix。
 
请告诉我,除了
  1. (action_tile "1" "(done_dialog 1)")
线?
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 18:57:22 | 显示全部楼层
 
 
  1. <p> </p><p>        (action_tile "cancel" [b]"(done_dialog 0)[/b]")</p><p>[b]            (setq optn (start_dialog))[/b]  ;;;--- Display the dialog box</p><p>           (unload_dialog dcl_id) ;;;--- Unload the dialog box</p><p>[b]    (if (> optn 0)(doButton optn))[/b]</p><p>        );; end progn3</p><p>      );; end (not (new_dialog "Select_Items" dcl_id))</p><p>[code]</p>
回复

使用道具 举报

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 19:04:23 | 显示全部楼层
我从来没有得到过,非常感谢你,显然你在创建lisp-DCL组合方面很熟练
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 19:17:53 | 显示全部楼层
 
 
 
不客气,继续练习:-)
 
 
 
 
不,我只是其中的一个,实际上我有时有点马虎,但迟早你自己糟糕的编码会在你面前爆发,你会努力做得更好。
 
 
gr.Rlx
回复

使用道具 举报

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 19:23:42 | 显示全部楼层
:-)         :-)         :-)        :-)        :-)        :-)        :-)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 20:05 , Processed in 0.531642 second(s), 79 queries .

© 2020-2025 乐筑天下

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