明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 702|回复: 3

求助:lisp中如何打开已有图形?

[复制链接]
发表于 2024-4-23 10:43:55 | 显示全部楼层 |阅读模式
lisp中如何打开已有图形?
发表于 2024-4-23 10:57:32 | 显示全部楼层
  1. (vlax-invoke-method (vlax-get-or-create-object "Wscript.Shell") 'run "dwg文件的完整路径")
复制代码
发表于 2024-4-23 11:09:17 | 显示全部楼层
;;106.1 [功能] 打开一个文件
;;示例: (MJ:OpenDwg "D:\\紫金防雨.dwg")(MJ:OpenDwg "D:\\DrawingA.dxf")
(defun MJ:OpenDwg (fullname)
  (command "vbastmt"
           (strcat "AcadApplication.Documents.Open "
                   (chr 34) fullname (chr 34)
           )
  )
)
;;106.2 [功能] 打开一个文件
;;示例(MJ:OpenDwg1 "D:\\紫金防雨.dwg")(MJ:OpenDwg1 "D:\\DrawingA.dxf")
(defun MJ:OpenDwg1 (fullname / *DOC*)
  (setq *DOCS* (vla-get-Documents *acad*))
  (vla-open *DOCS* fullname)
)
发表于 2024-4-23 13:31:07 | 显示全部楼层
;;  Uses the 'Open' method of the Shell Object to open the specified file or folder.
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com
;;  Arguments: target - file, folder or ShellSpecialFolderConstants enum
;;  Returns:  T if successful, else nil

(vl-load-com)
(defun LM:Open (target / shell result)
    (if
        (and
            (or
                (eq 'INT (type target))
                (setq target (findfile target))
            )
            (setq shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
        )
        (progn
            (setq result (vl-catch-all-apply 'vlax-invoke (list shell 'open target)))
            (vlax-release-object shell)
            (not (vl-catch-all-error-p result))
        )
    )
)

;Example to Open a File Selected by the User
(LM:Open (getfiled "Select File to Open" "" "" 16))

;Example to Open a Drawing File at a Specified Location:
(LM:Open "C:\\My Folder\\File.dwg")

;Example to Open a Directory:
(LM:Open "C:\\My Folder\\My SubFolder")

;Example to Open the Fonts Special Folder:
(LM:Open 20)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 04:40 , Processed in 0.153451 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表