明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1812|回复: 2

如何修改下面代码实现插入该图形

[复制链接]
发表于 2011-9-1 06:07:15 | 显示全部楼层 |阅读模式
求助:下面代码为点击合图表图号则打开与该图号同名的DWG文件,如何修改才能实现点击合图表号则指定基点(0,0)插入于图号同名的DWG文件(以块的方式,不分解)?
(defun C:opendwg()
(setq filel (getvar "users1"))
(if (= filel "")
  (progn
  (setq filel (qf_getFolder "选择图幅所在文件夹:"))
  (setvar "users1" filel)
))
(setq filename(strcat filel "\\" (setq name(cdr(assoc 1 (entget(car(entsel "\n选择图幅号:")))))) ".dwg"))
(if (findfile filename)
(progn
  (princ))
(progn
  (setq filel (qf_getFolder "重新指定图幅所在文件夹:"))
  (setvar "users1" filel)
  (setq filename(strcat filel "\\" name ".dwg"))
  ))
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) filename))
)
;;
(defun qf_getFolder (msg / WinShell shFolder path catchit)
  (vl-load-com)
  (setq winshell (vlax-create-object "Shell.Application"))
  (setq shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 msg 1))
  (setq
    catchit (vl-catch-all-apply
      '(lambda ()
(setq shFolder (vlax-get-property shFolder 'self))
(setq path (vlax-get-property shFolder 'path))
       )
    )
  )
  (if (vl-catch-all-error-p catchit)
    nil
    path
  )
)
发表于 2011-9-1 07:24:20 | 显示全部楼层
  1. (defun c:tt (/ name a path)
  2.   (setq        name (cdr (assoc 1 (entget (car (entsel "\n选择图幅号:")))))
  3.         name (strcat name ".dwg")
  4.   )
  5.   (if (setq a (findfile name))
  6.     (command "insert" a '(0 0) "" "" "")
  7.     (progn
  8.       (setq path (getvar "users1"))
  9.       (if (= path "")
  10.         (progn
  11.           (setq path (getFolder "选择图幅所在文件夹: "))
  12.           (setvar "users1" path)
  13.         )
  14.       )
  15.       (setq name (strcat path "\" name))
  16.       (if (setq a (findfile name))
  17.         (command "insert" a '(0 0) "" "" "")
  18.       )
  19.     )
  20.   )
  21.   (princ)
  22. )

  23. (defun getFolder (msg / WinShell shFolder path catchit path)
  24.   (vl-load-com)
  25.   (setq        winshell (vlax-create-object "Shell.Application")
  26.         shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 msg 1)
  27.         catchit         (vl-catch-all-apply
  28.                    '(lambda ()
  29.                       (setq shFolder (vlax-get-property shFolder 'self)
  30.                             path     (vlax-get-property shFolder 'path)
  31.                       )
  32.                     )
  33.                  )
  34.   )
  35.   (if (vl-catch-all-error-p catchit)
  36.     nil
  37.     path
  38.   )
  39. )

评分

参与人数 1金钱 +20 收起 理由
qfkxc + 20 很好用

查看全部评分

 楼主| 发表于 2011-9-1 18:19:46 | 显示全部楼层
多谢xyp1964的帮助,上面的功能程序很好用
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-9 21:47 , Processed in 0.149776 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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