乐筑天下

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

[编程交流] Can´t load nested lispfiles fr

[复制链接]

13

主题

36

帖子

23

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 08:54:05 | 显示全部楼层 |阅读模式
Hello, i have a problem with dcl which i´m new at.
 
This is just an example to see my problem.
An easy DLC file called test.dlc :
 
  1. test : dialog{label = "test dialog" ;: button{label = "Ok" ;key = "accepted" ;height = 1 ;width = 13 ;is_default = true ;}};; The lisp file to run the dialog:(defun test ( / flag dcl_id)(setq dcl_id (load_dialog "test.dcl"))(setq flag (new_dialog "test" dcl_id))(if (null flag) (exit))(action_tile "accepted" "(test_accepted)(done_dialog)")(start_dialog)(unload_dialog dcl_id))(defun test_accepted ()(load "SomeLispFile.lsp")(princ "hello")(alert "hello again")(command "snap" "on"))
 
When i run the test function everything works fine until it reaches an AutoCad command (in this case snap), then AutoCad stops responding.
It seems to be when a command is runned within the dialog function.
Anyone who know anything about this please help me!
 
Thanks in advance / Thomas
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:01:55 | 显示全部楼层
Please use the   Code Posting Guidline
回复

使用道具 举报

13

主题

36

帖子

23

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 09:09:27 | 显示全部楼层
I´m sorry..
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:15:25 | 显示全部楼层
 
No worries Thomas .
 
Welcome to the forum first .
 
All the hanging comes from the command call of snap , so replace it with the system variable like this .
 
  1. (setvar 'snapmode 1)
Besides that , your routine name which is SomeLispFile.lsp should be in the Acad support folder to be loaded and to let the routine running to end to put snap mode on also as well .
 
 
 
Hope this help .
 
Tharwat
回复

使用道具 举报

13

主题

36

帖子

23

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 09:19:55 | 显示全部楼层
Each time a drawing is opened a lisp file i loaded and that one loads another and so on.
My goal is to reload this sequence when the ok button is pressed but that isn´t possible as long as there is command calls in the lisp files?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:24:45 | 显示全部楼层
Yes this is what I meant in my last post .
 
Anyway here it is completely .
 
  1. (defun c:test ( / flag dcl_id)(setq dcl_id (load_dialog "test.dcl"))(setq flag (new_dialog "test" dcl_id))(if (null flag) (exit))(action_tile "accepted" "(test_accepted)(done_dialog)")(start_dialog)(unload_dialog dcl_id))(defun test_accepted ()(load "SomeLispFile.lsp")(princ "hello")(alert "hello again")(setvar 'snapmode 1))
 
Tharwat
回复

使用道具 举报

13

主题

36

帖子

23

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 09:30:50 | 显示全部楼层
Thanks Tharwat for your answers!
I rewrote all regular commands with setvar or with vl-commands so now it works just fine.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:41:40 | 显示全部楼层
I am so glad to hear that Thomas .
 
Tharwat
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:44:03 | 显示全部楼层
 
The issue is not with using command calls, but rather that the focus remains with the modal dialog when the command is called.
 
Instead, consider this code:
 
DCL:
  1. test : dialog { label = "test dialog" ;   ok_only;}
LISP:
  1. (defun test ( / id )   (cond       (   (< 0 (setq id (load_dialog "test.dcl")))           (cond               (   (new_dialog "test" id)                   (if (= 1 (start_dialog))                       (test_accepted)                   )               )           )           (unload_dialog id)       )   )   (princ))(defun test_accepted nil   (load "SomeLispFile.lsp")   (princ "hello")   (alert "hello again")   (setvar 'SNAPMODE 0))
回复

使用道具 举报

13

主题

36

帖子

23

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 09:50:49 | 显示全部楼层
Thank you Lee Mac!
It took me a while to understand but now I see that I can use whatever I want if I just close the dialog first.
Quite obvious when you know it...  
 
Nice to get an answer from a legend of this site!  (I have seen your answers many times on this site before I registered myself.)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 05:58 , Processed in 0.562943 second(s), 72 queries .

© 2020-2025 乐筑天下

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