明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2507|回复: 2

acad.lsp 中如何判断已加载了VBA工程

[复制链接]
发表于 2007-9-29 15:36:00 | 显示全部楼层 |阅读模式

(defun s::startup()
 ;(if (not S::startup)
 ;(setvar "cmdecho" 0)
 (command "_vbaload" "C:\\Program Files\\AA\\AA.dvb")
 (command "_vbarun" "AA")
;(setvar "cmdecho" 0)
 (princ)
)

这是加在ACAD.LSP里的语句,就是启动CAD时自动运行VBA程序.

我如何时才能判断是否已经加载了AA.DVB?以避免出现已加载的提示.

谢谢各位朋友.

 楼主| 发表于 2007-9-29 16:09:00 | 显示全部楼层

(defun s::startup()
 ;(if (not S::startup)
 ;(setvar "cmdecho" 0)
 (command "_vbarun" "C:\\Program Files\\AA\\AA.dvb!thisdrawing.AA")
;(setvar "cmdecho" 0)
 (princ)
)

为何在未启动CAD时,同时打开多个DWG图就会导致CAD死掉,

而在已启动CAD时,同时打开多个DWG图却没有问题?

发表于 2010-9-17 09:37:00 | 显示全部楼层
第四个例子是一个LISP例程。它使用相同的ActiveX对象判断一个工程是否已经加载,如果没有,就加载它。




(defun c:loadMyProject ()
;; This routine will load a project if it is not already loaded
;; the VBE (VB extensibility) ActiveX object is used to reference
;; the loaded projects
;; Load ActiveX  
(vl-load-com)
;; Get the VBE extisibility object  
(setq acadObject (vlax-get-acad-object))
(setq acadVbe (vla-get-vbe acadObject))
(setq acadVbeProjects (vlax-get-property acadVbe 'VBProjects))
;; Get the number of loaded VBA projects
(setq int1 (vlax-get-property acadVbeProjects 'count))
;; Counter and test variable named loaded  
(setq int2 1)
(setq loaded "False")
;; Repeat for each project  
(repeat int1
;; Itereate through the projects, getting the name of
;; next project, each time through  
(setq Item (vlax-invoke-method acadVbeProjects 'Item int2))
(setq pName (vlax-get-property Item 'Name))
  
;; Test the name for the name of the project I want to load
;; If it is already loaded the set the test variable to True
(if (= pName "my_test_project")
  (progn
     (prompt "\nmy_test_project is already loaded\n")
     (Setq Loaded "True")
  )
)
;; Increment the number used to get the next Project
(setq int2 (+ int2 1))
)
;; Load project if it is not already loaded by testing
;; the Loaded variable
(if (= Loaded "False")
(progn
  (princ "\nLoading my_test_project")
  (command "-VBALOAD"
            "D:/vba-apps/a-2000/already loaded test.dvb"
  )
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 22:59 , Processed in 0.151985 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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