Acad.lsp is reloaded when -VBARUN command is used in S::STARTUP
问题:
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 ACADLSPASDOCvariable is 0.
解答:
The reason that Acad.lsp is reloading, with a drawing opened by a procedure
inAcad.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))
页:
[1]