马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题:
Acad.lsp is reloading when -VBARUN command is used in the S::STARTUP function
to load a drawing. Is this known behavior and is there a way to stop it from
reloading? The ACADLSPASDOC variable is 0.
解答:
The reason that Acad.lsp is reloading, with a drawing opened by a procedure
in Acad.dvb (called with -VBARUN in S:STARTUP), is that AutoCAD has not finished
initializing at the point in the S::STARTUP function where the command -VBARUN
is called. As a workaround, the VBASTMT command allows you to call VBA functions
with arguments, from either the command line or a LISP expression. In this
case, we can use (vla-sendcommand) in the (S::STARTUP) function, to call the
VBA "RunMacro" method. This approach will not cause a reload of Acad.lsp.
- (defun-q mystartup ( )
- (vl-load-com) ;load ActiveX objects
- ;;replace this line: (command ".-vbarun" "MyModule.MySub")
- ;;with the following:
- (arxload "acadvba.arx") ;ensure Acad.dvb is loaded
- (vla-sendcommand
- (vla-get-activedocument (vlax-get-acad-object))
- "vbastmt\n\ThisDrawing.Application.RunMacro \"MyModule.MySub\"\n"
- )
- )
- (setq s::startup (append s::startup mystartup))
|