乐筑天下

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

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

[复制链接]

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 17:29:16 | 显示全部楼层 |阅读模式
So I designed a Button in DCL and it displays fine. However, I am trying to program it in Autolisp that when I click on the button, it will open a file in my computer. My code is:
 
SVNHRC.dwg
 
  (action_tile "b1"
    "command "_.FILEOPEN"D:\\Typical\\SVNHRC.dwg  ")
 
I do not know what is the proper way to pull up a command from autocad. Since you have to use quotation, and we have to use another quotation for the command.
 
Any help guys?
 
Thanks anyone in advance.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 17:34:05 | 显示全部楼层
You can not use a command call in action_tile so you need to replace it with a function.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:37:01 | 显示全部楼层
Here is a quick example for you to play with:
[code];; Open File Example  -  Lee Mac;; www.cadtutor.net/forum/showthread.php?97521(defun c:myopen ( / dch dcl des idx lst rtn )   (defun *error* ( msg )       (if (and (= 'int (type dch)) (
回复

使用道具 举报

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 17:39:44 | 显示全部楼层
Thanks Lee Mac,
I do not know if the last reply went out or not.
But this is a brilliant program.
 
However, for my program specifically,
I already know what file I wanted to open before I click the button,
since I already sorted the options out from former menus.
Thus, I just need to open a certain dwg file in the certain location.
 
I tried something like this:
 
  (action_tile "b1"
    "(OPFL)")
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
(defun OPFL ()
 
  (command "_.FILEOPEN" "D:\\Typical\\Template")
  )
 
Autocad froze every time when I click the button.
 
Sorry for the long extra question,
Thanks.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:43:18 | 显示全部楼层
 
Thank you.
 
 
As per my example above, you should evaluate the expression to open your file outside of the action_tile statement for your dialog tile, and after the dialog has been dismissed.
 
Since DCL dialogs are modal, AutoCAD cannot take focus whilst the dialog is displayed and will therefore freeze if attempting to evaluate a command without first dismissing the dialog.
回复

使用道具 举报

39

主题

180

帖子

141

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
195
发表于 2022-7-5 17:45:44 | 显示全部楼层
I didn't write this but works great.
 
  1. ;;; Opens the Architectural Standard details file.(defun c:OpenMySTD ( / _OpenDwg ) (vl-load-com)(defun _OpenDwg (dwg readOnly / doc) ;; BlackBox... Inspired by RenderMan, CADTutor.net ;; Example: (_OpenDwg "FilePath\\FileName.dwg" T) ;; Return: T, if successful; otherwise nil. (and (not        (vl-catch-all-error-p          (setq doc (vl-catch-all-apply                      'vla-open                      (list (vla-get-documents (vlax-get-acad-object))                            dwg                            (if readOnly                              :vlax-true                              :vlax-false                            )                      )                    )          )        )      )      (not (vla-activate doc)) ))  (_OpenDwg   "F:\\name of folder\\drawing name.DWG" [color=red][b];;; you need to change this line to where the file is that you want open.[/b][/color]   T) (princ))
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

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

铜币
362
发表于 2022-7-5 17:51:16 | 显示全部楼层
 
Well said, sir!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:53:23 | 显示全部楼层
 
Thank you!
回复

使用道具 举报

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 17:55:06 | 显示全部楼层
I have a follow up question, before you define LM:open, you wrote:
 
(setq rtn (start_dialog))
 
Does it run the dialog and give an return value?
and does it effect the function LM:open?
 
Thank you!
回复

使用道具 举报

10

主题

29

帖子

19

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-5 17:59:23 | 显示全部楼层
It's not LM:open, but
  1. LM:open
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:32 , Processed in 0.415042 second(s), 72 queries .

© 2020-2025 乐筑天下

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