乐筑天下

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

[编程交流] [DCL] Button to open a dwg fil

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:03:35 | 显示全部楼层
 
Yes, per the documentation for start_dialog:
 
There is a conditional statement at the end of the function definition for c:myopen which ensures [noparse]LM:open[/noparse] is only evaluated with the selected filename if rtn=1.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:06:41 | 显示全部楼层
Here is a simplified version:
[code];; Open File Example  -  Lee Mac;; www.cadtutor.net/forum/showthread.php?97521(defun c:myopen ( / dch dcl des dfn dwg rtn )   (setq dfn "D:\\Typical\\SVNHRC.dwg") ;; File to open   (defun *error* ( msg )       (if (and (= 'int (type dch)) (
回复

使用道具 举报

9

主题

51

帖子

42

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-5 18:09:54 | 显示全部楼层
Can have option to open other predefined (added) drawings within this lisp?
 
eg. myopen1 open A.dwg
myopen2 open B.dwg
 
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:12:45 | 显示全部楼层
Sure - without DCL the code can be simply:
  1. (defun c:open1 nil (LM:open "C:\\YourDrawing1.dwg") (princ))(defun c:open2 nil (LM:open "C:\\YourDrawing2.dwg") (princ))(defun c:open3 nil (LM:open "C:\\YourDrawing3.dwg") (princ));; Open  -  Lee Mac;; A wrapper for the 'Open' method of the Shell Object;; target - [int/str] File, folder or ShellSpecialFolderConstants enum(defun LM:open ( target / rtn shl )   (if (and (or (= 'int (type target)) (setq target (findfile target)))            (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))       )       (progn           (setq rtn (vl-catch-all-apply 'vlax-invoke (list shl 'open target)))           (vlax-release-object shl)           (if (vl-catch-all-error-p rtn)               (prompt (vl-catch-all-error-message rtn))               t           )       )   ))(vl-load-com) (princ)
回复

使用道具 举报

9

主题

51

帖子

42

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-5 18:13:58 | 显示全部楼层
Thanks Lee Mac.
回复

使用道具 举报

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 18:16:45 | 显示全部楼层
 
Thank you, sir. I am still trying to understand the code, but it works perfectly.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:20:40 | 显示全部楼层
Another way to look at it using a DCl with say a list box containing A B C D pick B you want to open "Drawing2" so after running the DCL you just need to set the name for the filename the (LM:OPEN TARGET / rtn shell) the value of Target is set to "Drawing2"
 
  1. something like this(cond((= picked "A")(LM:open "C:\\YourDrawing1.dwg"))((= picked "B")(LM:open "C:\\YourDrawing2.dwg"))........)
回复

使用道具 举报

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 18:25:13 | 显示全部楼层
 
  1.   (action_tile "accept" "(setq Project_Manager (get_tile "name")") (print Project_Manager) (setq p1 '(604 88.2))   (command "_text" p1 1 0 Project_Manager "")
 
In this case, why is it still not considered have the command outside of the action_tile?
 
Thanks
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 18:28:41 | 显示全部楼层
Let's first correct a syntax error:
 
A closing parenthesis is missing here:
  1. (action_tile "accept" "(setq Project_Manager (get_tile "name")")
It should be:
  1. (action_tile "accept" "(setq Project_Manager (get_tile "name"))")
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:30:55 | 显示全部楼层
 
Excellent - you're welcome.
 
 
Your expressions to perform operations in AutoCAD will need to be evaluated after the start_dialog expression.
 
The process is as follows:
 


  • load_dialog loads the contents of a DCL file into memory; the contents may define one or more modal dialogs.

 


  • new_dialog displays the modal dialog corresponding to the dialog definition of the given name, defined within the loaded DCL file.

 


  • set_tile/mode_tile expressions may be used to configure the various DCL tiles.

 


  • action_tile statements define a set of expressions that are to be evaluated when the user interacts with the DCL tile with the given key.

 


  • done_dialog may be evaluated to dismiss the displayed dialog and will return the position of the dialog when dimissed.

 


  • start_dialog allows the user to interact with the displayed dialog after processing all set_tile/mode_tile/action_tile statements to configure the behaviour of the dialog.
    This function will return the integer supplied by the done_dialog function.

As such, the dialog won't be displayed and cannot be configured until the new_dialog function is evaluated, but the displayed dialog is not operational until the start_dialog function is evaluated - therefore, if your code were to evaluate the new_dialog expression without a corresponding start_dialog expression, the modal dialog would be displayed but would not be able to be dismissed (AutoCAD must in terminated in this scenario).
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 08:57 , Processed in 0.670048 second(s), 70 queries .

© 2020-2025 乐筑天下

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