乐筑天下

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

[编程交流] LispVariable更新

[复制链接]

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:14:44 | 显示全部楼层 |阅读模式
我正在为rev框创建一个lisp,并在字段中使用LispVariables将rev数据存储在图形中。在我们的用户信息框之前,我使用下拉列表完成了这项工作,效果很好。我一启动它,它就会从图形中读取变量并更新对话框。我在其中使用了编辑框,但每次运行时它们不会更新到图形中的值。
有谁能帮忙吗?
还有一种方法可以基于第一个包含除“---”以外的任何内容的编辑框来控制块的可见性状态吗?
 
  1. Rev_box : dialog {    //dialog name
  2.      label = "Drawing Revisions" ;  //give it a label
  3. ////////////////////////////////////////////////////////////////////////////////////////////
  4.        :row {    //define boxed row
  5. //*********************************************************
  6.       : edit_box {    //define edit box
  7.         key = "ccc_rev1" ;   //give it a name
  8.         label = "Rev" ;   //give it a label
  9.         edit_limit = 2 ;   //6 characters only
  10.         edit_width = 2 ;   //6 characters only
  11.        }
  12. //*********************************************************  
  13.       : edit_box {    //define edit box
  14.         key = "ccc_by1" ;   //give it a name
  15.         label = "By" ;   //give it a label
  16.         edit_limit = 3 ;   //6 characters only
  17.         edit_width = 3 ;   //6 characters only
  18.         }
  19. //*********************************************************
  20.       : edit_box {    //define edit box
  21.         key = "ccc_date1" ;   //give it a name
  22.         label = "Date" ;   //give it a label
  23.         edit_limit = 10 ;   //6 characters only
  24.         edit_width = 9 ;   //6 characters only
  25.         }
  26. //*********************************************************
  27.       : edit_box {    //define edit box
  28.         key = "ccc_des1" ;   //give it a name
  29.         label = "Description" ;   //give it a label
  30.         edit_limit = 58 ;   //6 characters only
  31.         edit_width = 42 ;   //6 characters only
  32.         }
  33. //*********************************************************
  34.        :toggle {    //define toggle
  35.        key = "ccc_tog1";    //give it a name
  36.        label = "Line 1";   //give it a label
  37.        }     //end toggle
  38. //*********************************************************  
  39.        }     //end boxed row
  40. ok_cancel ;    //predifined OK/Cancel
  41.    
  42.     }      //end dialog

 
  1. (defun C:rev_box ()     ;define function
  2. (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
  3. (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
  4.      )
  5.    (exit)      ;exit if no dialog
  6. );if
  7.      (action_tile
  8.    "cancel"      ;if cancel button pressed
  9.    "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
  10.    );action_tile
  11.   (action_tile
  12.    "accept"      ;if O.K. pressed
  13.    " (done_dialog)(setq userclick T))"   ;close dialog, set flag
  14. );action tile
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. (action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
  17. (action_tile "ccc_by1" "(setq ccc_by_1 $value)")
  18. (action_tile "ccc_date1" "(setq ccc_date_1 $value)")
  19. (action_tile "ccc_des1" "(setq ccc_des_1 $value)")
  20. (start_dialog)     ;start dialog
  21.   (unload_dialog dcl_id)    ;unload
  22. (princ)
  23. (command "regenall")
  24. );defun C:samp
  25. (princ)
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:23:38 | 显示全部楼层
我试图强制平铺句柄接受CAD中变量的值。我用过这个:
 
  1. (defun C:rev_box ()     ;define function
  2. (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
  3. (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
  4.      )
  5.    (exit)      ;exit if no dialog
  6. [color=red] (setq ccc_rev1 ccc_rev_1)
  7. [/color]  );if
  8.      (action_tile
  9.    "cancel"      ;if cancel button pressed
  10.    "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
  11.    );action_tile
  12.   (action_tile
  13.    "accept"      ;if O.K. pressed
  14.    " (done_dialog)(setq userclick T))"   ;close dialog, set flag
  15. );action tile
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. (action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
  18. (action_tile "ccc_by1" "(setq ccc_by_1 $value)")
  19. (action_tile "ccc_date1" "(setq ccc_date_1 $value)")
  20. (action_tile "ccc_des1" "(setq ccc_des_1 $value)")
  21. (start_dialog)     ;start dialog
  22.   (unload_dialog dcl_id)    ;unload
  23. (princ)
  24. (command "regenall")
  25. );defun C:samp
  26. (princ)

 
这能做到吗?还是我在逆风吹口哨?
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:25:16 | 显示全部楼层
所以我发现了我的一些错误。
 
应如下所示:
 
  1. (defun C:rev_box ()     ;define function
  2. (setq dcl_id (load_dialog "rev_box.dcl"))  ;load dialog
  3. (if (not (new_dialog "rev_box" dcl_id)   ;test for dialog
  4.      )
  5.    (exit)      ;exit if no dialog
  6. );if
  7. [color=red](set_tile "ccc_rev1" ccc_rev_1)[/color]
  8.      (action_tile
  9.    "cancel"      ;if cancel button pressed
  10.    "(done_dialog) (setq userclick nil)"  ;close dialog, set flag
  11.    );action_tile
  12.   (action_tile
  13.    "accept"      ;if O.K. pressed
  14.    " (done_dialog)(setq userclick T))"   ;close dialog, set flag
  15. );action tile
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. (action_tile "ccc_rev1" "(setq ccc_rev_1 $value)")
  18. (action_tile "ccc_by1" "(setq ccc_by_1 $value)")
  19. (action_tile "ccc_date1" "(setq ccc_date_1 $value)")
  20. (action_tile "ccc_des1" "(setq ccc_des_1 $value)")
  21. (start_dialog)     ;start dialog
  22.   (unload_dialog dcl_id)    ;unload
  23. (princ)
  24. (command "regenall")
  25. );defun C:samp
  26. (princ)

 
这在图形中可以正常工作,但当我保存它时,请关闭它,然后返回。当我运行它时,会出现以下错误:
; 错误:错误的参数类型:stringp nil
 
安东有什么想法吗?
回复

使用道具 举报

62

主题

466

帖子

404

银币

后起之秀

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

铜币
310
发表于 2022-7-6 10:30:32 | 显示全部楼层
在lisp中尝试setq ccc\u rev\u 1。
 
尝试以下操作:
  1. (defun C:rev_box (/ dcl_id ccc_rev1)
  2. [color=darkred][b](setq ccc_rev1 ???)[/b][/color]
  3. ;;and so on...

 
 
ps
编辑帖子,这样其他用户就不必阅读您的所有帖子来提供他们的输入。
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:36:55 | 显示全部楼层
谢谢丹中尉的腿,但那没用。问题似乎是,当我在对话框中输入值时,这些值在CAD中被创建为LispVariables,并且我用这些变量设置了字段。如果保存图形并重新打开,字段仍然包含位于最右侧字段对话框顶部的变量,但它们不再在变量列表中。有什么办法吗?有没有办法让CAD保存图形中的字段?
 
111444uoc4q61op165rwq4.png
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:41:32 | 显示全部楼层
是否有某种方法可以让CAD在lisp完成后存储字段,这样当我再次打开图形时,这些字段仍然存在,并传递到DCL并显示在正确的编辑框中。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 10:43:52 | 显示全部楼层
之前已经讨论过在dwg搜索中存储数据以获取扩展实体。还可以看看useri1-5 userr1-5 users1-5。
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:49:36 | 显示全部楼层
 
伍德曼78,
 
这是可行的。还请注意,我去掉了所有那些无用的评论,并对瓷砖进行了更改。这是您的问题(set\u tile“ccc\u rev1”ccc\u rev\u 1)。
还将此Rev\u框更改为此Rev\u框。
 
 
 
对话
  1. [color=red]rev_box[/color] : dialog { label = "Drawing Revisions";
  2.          : row  {
  3.            : edit_box { label = "Rev";         key = "ccc_rev1";  edit_limit = 2;  edit_width = 2;  }
  4.            : edit_box { label = "By" ;         key = "ccc_by1" ;  edit_limit = 3;  edit_width = 3;  }
  5.            : edit_box { label = "Date";        key = "ccc_date1"; edit_limit = 10; edit_width = 9;  }
  6.            : edit_box { label = "Description"; key = "ccc_des1";  edit_limit = 58; edit_width = 42; }
  7.            : toggle   { label = "Line 1";      key = "ccc_tog1";  }
  8.          }
  9. [color=red]          : button { label = "&Ok";   key = "accept"; width = 18; fixed_width = true; alignment = centered; is_default = true; }  [/color]
  10. [color=red]          : button { label = "&Exit"; key = "cancel"; width = 18; fixed_width = true; alignment = centered; is_cancel = true;  }[/color]
  11. [color=red]        }[/color]

 
 
Lisp程序
  1. (defun C:rev_box ()
  2. [color=red](or ccc_rev_1 (setq ccc_rev_1 "1"))[/color]
  3. (setq dcl_id (load_dialog "rev_box.dcl"))
  4. (if (not (new_dialog "rev_box" dcl_id))
  5.    (exit))
  6. (set_tile [color=red]"ccc_rev1"[/color] ccc_rev_1)
  7. (action_tile "ccc_rev1"  "(setq ccc_rev_1  $value)")
  8. (action_tile "ccc_by1"   "(setq ccc_by_1   $value)")
  9. (action_tile "ccc_date1" "(setq ccc_date_1 $value)")
  10. (action_tile "ccc_des1"  "(setq ccc_des_1  $value)")
  11. (action_tile "cancel"    "(done_dialog)(setq userclick nil)")
  12. (action_tile "accept"    "(done_dialog)(setq userclick T))")
  13. (start_dialog)
  14. (unload_dialog dcl_id)
  15. [color=red] (if userclick[/color]
  16. [color=red]  (progn[/color]
  17. [color=red]    (command "._regenall")))[/color]
  18. [color=red](princ))[/color]
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:55:48 | 显示全部楼层
 
 
请参见此处:http://www.afralisp.net/archive/lispa/lisp50.htm
回复

使用道具 举报

32

主题

1166

帖子

1146

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2022-7-6 10:59:30 | 显示全部楼层
下面的代码称为RBOX,它设置了所有平铺并填充了默认数据。注意,它们被设置为全局变量。试图为你节省一些时间。
这仅适用于当前绘图任务。有关每次打开图形时从上次绘图任务中保存的数据,请参见上面文章中的链接。
 
RBOX。dcl
  1. RBOX : dialog { label = "Drawing Revisions";
  2.       : row  {
  3.         : edit_box { label = "Rev";         key = "ccc_rev1";  edit_limit = 2;  edit_width = 2;  }
  4.         : edit_box { label = "By" ;         key = "ccc_by1" ;  edit_limit = 3;  edit_width = 3;  }
  5.         : edit_box { label = "Date";        key = "ccc_date1"; edit_limit = 10; edit_width = 9;  }
  6.         : edit_box { label = "Description"; key = "ccc_des1";  edit_limit = 58; edit_width = 42; }
  7.         : toggle   { label = "Line 1";      key = "ccc_tog1";  }
  8.       }
  9.       : button { label = "&Ok";   key = "accept"; width = 18; fixed_width = true; alignment = centered; is_default = true; }  
  10.       : button { label = "&Exit"; key = "cancel"; width = 18; fixed_width = true; alignment = centered; is_cancel = true;  }
  11.     }

 
RBOX。lsp
 
  1. (defun C:RBOX ()
  2. (or RBOX:ccc_rev_1  (setq RBOX:ccc_rev_1  "1"))
  3. (or RBOX:ccc_by_1   (setq RBOX:ccc_by_1   "WM"))
  4. (or RBOX:ccc_date_1 (setq RBOX:ccc_date_1 "10/22/10"))
  5. (or RBOX:ccc_des_1  (setq RBOX:ccc_des_1  "ISSUED FOR CONSTRUCTION"))
  6. (or RBOX:ccc_tog_1  (setq RBOX:ccc_tog_1  "1"))
  7. (setq dcl_id (load_dialog "RBOX.dcl"))
  8. (if (not (new_dialog "RBOX" dcl_id))
  9.    (exit))
  10. (set_tile "ccc_rev1"  RBOX:ccc_rev_1)
  11. (set_tile "ccc_by1"   RBOX:ccc_by_1)
  12. (set_tile "ccc_date1" RBOX:ccc_date_1)
  13. (set_tile "ccc_des1"  RBOX:ccc_des_1)
  14. (set_tile "ccc_tog1"  RBOX:ccc_tog_1)
  15. (action_tile "ccc_rev1"  "(setq RBOX:ccc_rev_1  $value)")
  16. (action_tile "ccc_by1"   "(setq RBOX:ccc_by_1   $value)")
  17. (action_tile "ccc_date1" "(setq RBOX:ccc_date_1 $value)")
  18. (action_tile "ccc_des1"  "(setq RBOX:ccc_des_1  $value)")
  19. (action_tile "ccc_tog1"  "(setq RBOX:ccc_tog_1     $value)")
  20. (action_tile "cancel"    "(done_dialog)(setq userclick nil)")
  21. (action_tile "accept"    "(done_dialog)(setq userclick T))")
  22. (start_dialog)
  23. (unload_dialog dcl_id)
  24. (if userclick
  25.    (progn
  26.      (command "._regenall")))
  27. (princ))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 19:50 , Processed in 0.561241 second(s), 74 queries .

© 2020-2025 乐筑天下

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