Jump to content

Loading Vba Programs only once with Lisp


muck

Recommended Posts

Using AutoCad 2010.

 

I have used the following proceedure to load my VBA rounines.

I run the proceedure during startup and the keyin the command when I want to use may routine.

 

If I use the command twice the vba program loads twice.

 

Is there a way to test a vba program to see if it is allready load then load

the program only if it is not loaded.

 

The proceedure is listed is below:

(defun C:opn ()

(vl-vbaload "C:/PgCADvba/OpenDrawing.dvb")

(vl-vbarun "opn")

)

 

Thank you,

Link to comment
Share on other sites

I don't know if there is a way of doing that one but how about load your VBA then run then unload it once you have finished.

 

(command "_vbaload" "myfile.dvb")

(command "filedia" 1)

(command "-vbarun" "mf")

(command "_vbaunload" "myfile.dvb")

 

Hope this helps

Link to comment
Share on other sites

I am looking for a program that checks to see if a VBA program is allready loaded.

If loaded, don't load it again. If it is not loaded the program needs to load it.

Is there a way to do that?

Thank you,

Link to comment
Share on other sites

This *may* be what you're after...

 

Command Macro:

^C^C^P(if (not c:[color=red][i]FOO[/i][/color]) (load "[color=red][i]<FilePath>[/i][/color]\\[color=red][i]FOO[/i][/color].lsp")) c:[color=red][i]FOO[/i][/color]

 

 

 

LISP Command:

(defun c:[color=red][i]FOO[/i][/color] (/ appName)
 (vl-load-com)
 (setq appName (strcat "[color=red][i]<FilePath>[/i][/color][color=#000000]\\[color=red][i]<FileName>[/i][/color].dvb" "![color=red][i]<MacroName>[/i][/color].lrb"))[/color]
 (vl-vbarun appName)
 (princ))

 

 

Now, to unload the VBA Macro...

 

Either include a sub-function call at the end of your macro, or use a command reactor (reference the :vlr-CommandEnded event in the Developer Documentation) to run:

 

(vla-unloaddvb [color=red][i]<ApplicationObject>[/i][/color])

 

 

Hope this helps!

 

Edit:

Be sure to use

 tags.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...