execute mnl only on autocad startup?

execute mnl only on autocad startup?

Anonymous
Not applicable
802 Views
17 Replies
Message 1 of 18

execute mnl only on autocad startup?

Anonymous
Not applicable
looks like I've build a nice deathtrap. However, maybe someone has an idea? I have a mnl file loaded with my mnu which does: - load my vlx - define some commands - set some variables Recently it became necessary to set several options with every autocad startup, so I included the following line in the mnl: (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") Normally this works without problems. Now I've got a vba program which exports objects on certain layers using wblock. Dependent on user's choice either one drawing or a bunch of drawings are created and at last opened. The problem: If more than one drawing are opened, only the last one is opened completely, the others are locking up whilst executing the startup macro and cannot be closed afterwards ("AutoCAD can't close drawing because a command is still active...") Can I achieve the mnl to be executed only on Autocad startup? Or is there a possibility to execute a vba macro only once in a autocad session? TIA, Kathrin
0 Likes
803 Views
17 Replies
Replies (17)
Message 2 of 18

Anonymous
Not applicable
Create a project and save it in a file called acad.dvb. In a public module, create a sub called AcadStartup and put your code there. I posted one a week or so ago that you can download which toggles caps lock. you can use that to start with. -- ---- Ed ---- "Kathrin Bombrowski" wrote in message news:40740955_2@newsprd01... > looks like I've build a nice deathtrap. However, maybe someone has an idea? > > I have a mnl file loaded with my mnu which does: > - load my vlx > - define some commands > - set some variables > > Recently it became necessary to set several options with every autocad > startup, so I included the following line in the mnl: > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") > > Normally this works without problems. > > Now I've got a vba program which exports objects on certain layers using > wblock. Dependent on user's choice either one drawing or a bunch of drawings > are created and at last opened. > The problem: If more than one drawing are opened, only the last one is > opened completely, the others are locking up whilst executing the startup > macro and cannot be closed afterwards ("AutoCAD can't close drawing because > a command is still active...") > > Can I achieve the mnl to be executed only on Autocad startup? > Or is there a possibility to execute a vba macro only once in a autocad > session? > > TIA, > Kathrin > > >
0 Likes
Message 3 of 18

Anonymous
Not applicable
Thanks for the suggestion, Ed. If I use "common" files like acad.dvb or acad.lsp I'll have to make sure that they are not used by one of the various 3rd party applications we have in use, and this for 160 machines. So I would prefer a solution where I'm completely independent from such commonly used files. "Ed Jobe" schrieb im Newsbeitrag news:40740b1b$1_1@newsprd01... > Create a project and save it in a file called acad.dvb. In a public module, > create a sub called AcadStartup and put your code there. I posted one a week > or so ago that you can download which toggles caps lock. you can use that to > start with. > > -- > ---- > Ed > ---- > "Kathrin Bombrowski" wrote in > message news:40740955_2@newsprd01... > > looks like I've build a nice deathtrap. However, maybe someone has an > idea? > > > > I have a mnl file loaded with my mnu which does: > > - load my vlx > > - define some commands > > - set some variables > > > > Recently it became necessary to set several options with every autocad > > startup, so I included the following line in the mnl: > > > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") > > > > Normally this works without problems. > > > > Now I've got a vba program which exports objects on certain layers using > > wblock. Dependent on user's choice either one drawing or a bunch of > drawings > > are created and at last opened. > > The problem: If more than one drawing are opened, only the last one is > > opened completely, the others are locking up whilst executing the startup > > macro and cannot be closed afterwards ("AutoCAD can't close drawing > because > > a command is still active...") > > > > Can I achieve the mnl to be executed only on Autocad startup? > > Or is there a possibility to execute a vba macro only once in a autocad > > session? > > > > TIA, > > Kathrin > > > > > > > >
0 Likes
Message 4 of 18

Anonymous
Not applicable
Kathrin, This is a shot in the dark, but maybe if you try something like the following in the .MNL file, the reentry could be avoided. (vl-load-com) (if (= gbHasInitialized 'nil) (progn (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") ;DO YOUR STUFF HERE! (setq gbHasInitialized T) ;Set a flag to show that your stuff has been done! (vl-propagate 'gbHasInitialized ) ;Propagate the value to all drawings ) ;_end of progn ) ;_end of if Wayne "Kathrin Bombrowski" wrote in message news:40740955_2@newsprd01... > looks like I've build a nice deathtrap. However, maybe someone has an idea? > > I have a mnl file loaded with my mnu which does: > - load my vlx > - define some commands > - set some variables > > Recently it became necessary to set several options with every autocad > startup, so I included the following line in the mnl: > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") > > Normally this works without problems. > > Now I've got a vba program which exports objects on certain layers using > wblock. Dependent on user's choice either one drawing or a bunch of drawings > are created and at last opened. > The problem: If more than one drawing are opened, only the last one is > opened completely, the others are locking up whilst executing the startup > macro and cannot be closed afterwards ("AutoCAD can't close drawing because > a command is still active...") > > Can I achieve the mnl to be executed only on Autocad startup? > Or is there a possibility to execute a vba macro only once in a autocad > session? > > TIA, > Kathrin > > >
0 Likes
Message 5 of 18

Anonymous
Not applicable
Kathrin, On second thought, this order may be better: (vl-load-com) (if (= gbHasInitialized 'nil) (progn (setq gbHasInitialized T) ;Set a flag to show that your stuff has been done! (vl-propagate 'gbHasInitialized ) ;Propagate the value to all drawings (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") ;DO YOUR STUFF HERE! ) ;_end of progn ) ;_end of if Wayne "Wayne Craig" wrote in message news:407445aa_2@newsprd01... > Kathrin, > > This is a shot in the dark, but maybe if you try something like the > following in the .MNL file, the reentry could be avoided. > > (vl-load-com) > (if (= gbHasInitialized 'nil) > (progn > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") ;DO YOUR STUFF HERE! > (setq gbHasInitialized T) ;Set a flag to show that your stuff has been > done! > (vl-propagate 'gbHasInitialized ) ;Propagate the value to all drawings > ) ;_end of progn > ) ;_end of if > > Wayne > > > > > > "Kathrin Bombrowski" wrote in > message news:40740955_2@newsprd01... > > looks like I've build a nice deathtrap. However, maybe someone has an > idea? > > > > I have a mnl file loaded with my mnu which does: > > - load my vlx > > - define some commands > > - set some variables > > > > Recently it became necessary to set several options with every autocad > > startup, so I included the following line in the mnl: > > > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") > > > > Normally this works without problems. > > > > Now I've got a vba program which exports objects on certain layers using > > wblock. Dependent on user's choice either one drawing or a bunch of > drawings > > are created and at last opened. > > The problem: If more than one drawing are opened, only the last one is > > opened completely, the others are locking up whilst executing the startup > > macro and cannot be closed afterwards ("AutoCAD can't close drawing > because > > a command is still active...") > > > > Can I achieve the mnl to be executed only on Autocad startup? > > Or is there a possibility to execute a vba macro only once in a autocad > > session? > > > > TIA, > > Kathrin > > > > > > > >
0 Likes
Message 6 of 18

Anonymous
Not applicable
Use one of AutoCAD's USER variables and test it for a value. In your DVB Startup, have it set the variable after it runs. Would look something like: (if(=(getvar"USERS1")"RUN") (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup"))
0 Likes
Message 7 of 18

Anonymous
Not applicable
You might try using acad.lsp and appending your code to the (s::startup) function. By appending, no matter what others have done, yours still gets run. Try this: ;;; Written by: Vladimir Nesterovsky (defun PlugIntoStartup (MyFunc) ; "to be called with quoted function name" (eval (list 'defun 'S::StartUp () (if S::StartUp (list (list 'quote S::StartUp)) ) (list MyFunc) ) ) ) ;;; Usage: (PlugIntoStartup 'MyDoOpen) ;;; ;;; where MyDoOpen is your startup code: ;;; (defun MyDoOpen () ;;; (defun c:mtext() (c:settxt)) ;;; (defun c:text() (c:settxt)) ;;; (defun c:dtext() (c:settxt)) ;;; (command "._undefine" "mtext" "._undefine" "text" "._undefine" "dtext") ;;; (princ) ;;; ) -- ---- Ed ---- "Mike Tuersley" wrote in message news:1vwhx4157c58d$.6vnmwgk6lvov$.dlg@40tude.net... > Use one of AutoCAD's USER variables and test it for a value. In your DVB > Startup, have it set the variable after it runs. Would look something like: > > (if(=(getvar"USERS1")"RUN") > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup"))
0 Likes
Message 8 of 18

Anonymous
Not applicable
Also, if you are worried about moving code to 160 machines, most cad mgrs have a utility for copying files to the clients. For example, I have an Access db on the network that startup functions look to. It has a table for that lists users and the last time they updated and a table listing the updates/date. Now, when I want to do an update, all I do is change the date of the update, if the users update is older than the update's date, a program is launched to copy the files. You could do it without the db, but the db allows me to see where everyone's at. -- ---- Ed ----
0 Likes
Message 9 of 18

Anonymous
Not applicable
Wayne, your solution looks closest to what I want, but I can't bring it to work. The thing is, when opening a new drawing the mnl is executed first and then the vl-propagate works. Very annoying. "Wayne Craig" schrieb im Newsbeitrag news:407445aa_2@newsprd01... > Kathrin, > > This is a shot in the dark, but maybe if you try something like the > following in the .MNL file, the reentry could be avoided. > > (vl-load-com) > (if (= gbHasInitialized 'nil) > (progn > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") ;DO YOUR STUFF HERE! > (setq gbHasInitialized T) ;Set a flag to show that your stuff has been > done! > (vl-propagate 'gbHasInitialized ) ;Propagate the value to all drawings > ) ;_end of progn > ) ;_end of if > > Wayne > > > > > > "Kathrin Bombrowski" wrote in > message news:40740955_2@newsprd01... > > looks like I've build a nice deathtrap. However, maybe someone has an > idea? > > > > I have a mnl file loaded with my mnu which does: > > - load my vlx > > - define some commands > > - set some variables > > > > Recently it became necessary to set several options with every autocad > > startup, so I included the following line in the mnl: > > > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup") > > > > Normally this works without problems. > > > > Now I've got a vba program which exports objects on certain layers using > > wblock. Dependent on user's choice either one drawing or a bunch of > drawings > > are created and at last opened. > > The problem: If more than one drawing are opened, only the last one is > > opened completely, the others are locking up whilst executing the startup > > macro and cannot be closed afterwards ("AutoCAD can't close drawing > because > > a command is still active...") > > > > Can I achieve the mnl to be executed only on Autocad startup? > > Or is there a possibility to execute a vba macro only once in a autocad > > session? > > > > TIA, > > Kathrin > > > > > > > >
0 Likes
Message 10 of 18

Anonymous
Not applicable
But aren't user variables only valid within the drawing they were set? "Mike Tuersley" schrieb im Newsbeitrag news:1vwhx4157c58d$.6vnmwgk6lvov$.dlg@40tude.net... > Use one of AutoCAD's USER variables and test it for a value. In your DVB > Startup, have it set the variable after it runs. Would look something like: > > (if(=(getvar"USERS1")"RUN") > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup"))
0 Likes
Message 11 of 18

Anonymous
Not applicable
True, and the string vars are not saved at all. That's why I suggest S::Startup in acad.lisp. -- ---- Ed ---- "Kathrin Bombrowski" wrote in message news:40746f21_1@newsprd01... > But aren't user variables only valid within the drawing they were set? > > "Mike Tuersley" schrieb im Newsbeitrag > news:1vwhx4157c58d$.6vnmwgk6lvov$.dlg@40tude.net... > > Use one of AutoCAD's USER variables and test it for a value. In your DVB > > Startup, have it set the variable after it runs. Would look something > like: > > > > (if(=(getvar"USERS1")"RUN") > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup")) > >
0 Likes
Message 12 of 18

Anonymous
Not applicable
You know what, I misinformed you. S::Startup runs on each new dwg, don't know what I was thinking. You simply want to append to the acad.lsp file. Don't replace the file, just append to it. You could do it with vba and the Write function when you Open a text file for Append. Then the next time they start acad, your code will be loaded. -- ---- Ed ---- "Ed Jobe" wrote in message news:40747ab7$1_1@newsprd01... > True, and the string vars are not saved at all. That's why I suggest > S::Startup in acad.lisp. > > -- > ---- > Ed > ---- > "Kathrin Bombrowski" wrote in > message news:40746f21_1@newsprd01... > > But aren't user variables only valid within the drawing they were set? > > > > "Mike Tuersley" schrieb im Newsbeitrag > > news:1vwhx4157c58d$.6vnmwgk6lvov$.dlg@40tude.net... > > > Use one of AutoCAD's USER variables and test it for a value. In your DVB > > > Startup, have it set the variable after it runs. Would look something > > like: > > > > > > (if(=(getvar"USERS1")"RUN") > > > (vl-vbarun "gb_AO.dvb!M_Startup.GB_startup")) > > > > > >
0 Likes
Message 13 of 18

Anonymous
Not applicable
Thanks Ed, the PlugIntoStartup thing works great. Though I'd rather avoid acad.lsp, it seems to be the only solution for my problem. Many thanx also for your suggestion regarding the update db. It's a great idea and I'll deal with it as soon as I can find the time. greetings from Germany, Kathrin "Ed Jobe" schrieb im Newsbeitrag news:40745beb$1_3@newsprd01... > Also, if you are worried about moving code to 160 machines, most cad mgrs > have a utility for copying files to the clients. For example, I have an > Access db on the network that startup functions look to. It has a table for > that lists users and the last time they updated and a table listing the > updates/date. Now, when I want to do an update, all I do is change the date > of the update, if the users update is older than the update's date, a > program is launched to copy the files. You could do it without the db, but > the db allows me to see where everyone's at. > > -- > ---- > Ed > ---- > >
0 Likes
Message 14 of 18

Anonymous
Not applicable
"Ed Jobe" schrieb im Newsbeitrag news:40747f72$1_3@newsprd01... > You know what, I misinformed you. S::Startup runs on each new dwg, This is what help says, too. Remember, my intention was a routine which runs only on acad startup. What I completely dont understand (maybe because its late night here) is, why does it work for me then? I have the acad.lsp with a "hollow" S::Startup and in the .mnl I append my startup macro using the PlugIntoStartup function. And it runs definitely not on each new dwg. Kathrin
0 Likes
Message 15 of 18

Anonymous
Not applicable
I think what is happening is you have got Acad.lsp set to load only on startup and if I am correct you are appending to this. Therefore if you had Acad.lsp set to load with every drawing it would run in every drawing. It sounds like it works for you and you just needed to know why so I hope that clarifies it.
Regards - Nathan
0 Likes
Message 16 of 18

Anonymous
Not applicable
ACADLSPASDOC is the system variable you should read about. Also, look for LISPINIT system variable -- Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica (sorry, phony e-mail, SPAM made me do it) "Kathrin Bombrowski" wrote in message news:407487a0_2@newsprd01... > "Ed Jobe" schrieb im Newsbeitrag > news:40747f72$1_3@newsprd01... > > You know what, I misinformed you. S::Startup runs on each new dwg, > > This is what help says, too. Remember, my intention was a routine which runs > only on acad startup. > What I completely dont understand (maybe because its late night here) is, > why does it work for me then? > I have the acad.lsp with a "hollow" S::Startup and in the .mnl I append my > startup macro using the PlugIntoStartup function. And it runs definitely not > on each new dwg. > > Kathrin > >
0 Likes
Message 17 of 18

Anonymous
Not applicable
"Kathrin Bombrowski" wrote > But aren't user variables only valid within the drawing they were set? > You can set LISP variables that have application-level scope using (vl-bb-set), and read them with (vl-bb-ref). Hence: (defun AppInit () (if (not (vl-bb-ref 'zzz:done)) (progn (vl-bb-set 'zzz:done t) (RunOnce) ) ) ) (defun RunOnce () ;; Code here will run only once per session ) Then, from some place (code executed at startup), just call the (AppInit). You can call that any number of times, but the (RunOnce) function is called only once, the first time AppInit is called. -- http://www.caddzone.com AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005 http://www.acadxtabs.com AcadX for AutoCAD 2004 Beta 1 http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
0 Likes
Message 18 of 18

Anonymous
Not applicable
YEAAAHH, thats the solution I was looking for. Wasn't aware of the blackbord namespace. Many thanks, Tony! Kathrin
0 Likes