明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: lcy_8031

用Lsp打开文件

  [复制链接]
发表于 2010-12-19 19:34:07 | 显示全部楼层
正急需中,谢谢啦!
发表于 2010-12-20 08:58:46 | 显示全部楼层
nonsmall 发表于 2008-11-27 14:46
(defun c:op()(setq dwg (getstring "文件名:"))(setq path "D:\\temp\\");你自己定义路径吧(if (and (/= " ...

老猫的方法一定很好
不过,怎么加上对话框,选择路径,就不用设定路径了
然后把路径注册到注册表里,
输入命令时候判断是否有路径,
有路径就不用弹出选择路径的对话框了
发表于 2010-12-20 10:27:51 | 显示全部楼层
本帖最后由 qcw911 于 2010-12-20 11:09 编辑

想到了,
感谢老猫思路
特别感谢Gu_xl添加反斜杠方法

(defun c:tt()
  (setq path (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path"))
  (if  (= nil path)
(progn
   (setq path (AddBS(Get_Folder)))
   (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path")
          (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path" path)
   (setq path (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\win_path" "win_path"))
)
)
   (setq dwg (getstring "請輸入文件名:"))
;;;   (setq path "D:\\temp\\")
   (if (and (/= "" dwg)(findfile (strcat path dwg ".dwg")))
       (vla-open (vla-get-documents(vlax-get-acad-object)) (strcat path dwg ".dwg"))
       (alert "沒有該文件")
   )
)
(defun Get_Folder( / path_object shell)
(setq shell (Vlax-Get-Or-Create-Object "Shell.Application" ))
(if (setq path_object (vlax-invoke shell 'BrowseForFolder 0 "" 0 0))
  (vlax-get (vlax-get path_object 'Self) 'Path)
)
)
;;;==================================================================
;;; (AddBS cPath) 按需添加反斜杠符到路径中。
;;;------------------------------------------------------------------
;;; 参数:
;;;     cPath  使用路径。
;;;------------------------------------------------------------------
;;; 返回:
;;;     [STR]  cPath 添加了反斜杠符的路径
;;; 示例:  (setq a "C:\\MyFolder")
;;;        (AddBS a) ;
;;;               返回 "C:\\MyFolder\\"
;;;==================================================================
(defun AddBS (cPath)
  (if(not (= (substr cPath (strlen cPath)) "\\"))
    (strcat cPath "\\")
      cPath
    ) ;_ end of if
)

发表于 2010-12-20 23:14:39 | 显示全部楼层
MARK~~~~~~~~~~~
发表于 2010-12-20 23:19:05 | 显示全部楼层
路过,学习了
谢谢楼上的分享
发表于 2011-6-26 21:23:56 | 显示全部楼层
回复 qcw911 的帖子

我想要以“Ctrl+o”的方式打开一个指定的文件夹,那要怎样的程序呢?
很希望得到大师的帮助!
发表于 2011-6-27 04:21:41 | 显示全部楼层
路过,学习了
谢谢楼上的分享
发表于 2011-7-8 00:09:40 | 显示全部楼层
(DEFUN C:DK1 ()
(vlax-invoke
  (vlax-create-object "Shell.Application")
  'open
  "c:\\Program Files\\Google";;文件或路径名
))
发表于 2012-1-7 11:08:18 | 显示全部楼层
厉害,赞一个
发表于 2015-12-18 09:59:33 | 显示全部楼层
学习学习学习!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-17 23:57 , Processed in 0.186426 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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