Author Topic: Successful If statement prompt  (Read 7295 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Successful If statement prompt
« Reply #15 on: March 22, 2005, 08:59:58 PM »
Quote from: sinc

The acad.lsp file is loaded at Autocad startup - BEFORE any drawings are loaded.  You should not have any commands in it that require an open drawing.  Things loaded in this file are handled specially, and are not automatically loaded into documents namespaces.  Unless you really know what you're doing, you should probably avoid the acad.lsp file altogether.

The acaddoc.lsp file is a good place for loading custom commands.  This file is executed every time a drawing is opened, but it happens before drawing initialization is complete.  Therefore, you can put things like "load" commands in here, but you can't put some other things in here (like "undefine").

sinc,
Although there is great advice here, I must advise ronjonp that it's not all exactly correct. The biggest thing is that acad.lsp does, in fact, affect the first opened drawing (provided ACADLSPASDOC is set to 0) only, so any drawing specific variables will only be good for that first drawing. However, if you add a (command "undefine" "whatever"), that command will get undefined for the entire editing session, no matter which drawing you are in. I used to have my system setup this way, prior to the MDI. However, I still agree with you that this is NOT the place for most things to be placed. About the ONLY thing that should be in here, IMHO, is (vl-load-com).

Next, I place ALL of my setup type & customization stuff in my own .lsp file that I call from mymenu.mnl. I do it this way so that when I upgrade or even just reinstall I know what I need to add to the new install to be back up and running in a minimal amount of time. All I have to do is menuload mymenu once and it will be loaded from then on out......plus I don't need to worry about the acad.lsp or acaddoc.lsp files being overwritten or duplicated by others.

And as I said in my reply to ronjonp in that other thread, I used to have problems with the StartUpSuite. More often than not I would not have my custom routines loaded. That was the big driving force for me to place all of my startup apps in the mnl file.....voila', no more problems ;)

For the record, "mymenu" was used for reference only and does not represent any real, or percieved to be real, menu file(s).

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Successful If statement prompt
« Reply #16 on: March 22, 2005, 09:30:54 PM »
Jeff
I too have my own AlansAutoload.lsp, which is called from ACADDOC.lsp as it loads
in every DWG.
Is your lsp file is mymenu.mnl called automatically or do you have a button to force it?
Is the MNL file loaded with each DWG opened and therefore runs the lsp in each DWG.
I am in the process of moving to 2004 but the many lisp, menus & buttons are scattered
so i am trying to consolidate them into my menu system. It is working for the most part
but the ICONS for the buttons are a PITA. The ones I created & named were copied to a new
name by ACAD2000 & I don't feel like changing them all back. I ended up just copying all
icons from ACAD2000 to the MyDocuments directory. This doesn't sit right with me as it
clutters that directory. I think they should be in there own directory. I see some people
gather them up in a DLL file but I'm not sure of the over head for added & editing the
icons.
I would be interested in how you manage your system if you have the time & interest in sharing
your thought on the subject.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7529
Successful If statement prompt
« Reply #17 on: March 22, 2005, 10:23:44 PM »
CAB,

Quote
Is the MNL file loaded with each DWG opened and therefore runs the lsp in each DWG.


From my experience yes.
Quote

I too have my own AlansAutoload.lsp, which is called from ACADDOC.lsp as it loads
in every DWG.


I used to do it this way but if a menu is constantly loaded loaded in a profile and the menu.mnl file will send commands....it seemed easy to just use the mnl file to load what I needed. From Jeff's explanation...I can see now that it is better to name the lisp file being called something different that acad(doc).lsp to ensure you aren't interfering with anything AutoCAD loads normally. I was under the impression that acad(doc).lsp didn't exist unless the user created them.

I have all my icons in a dll file and love it. Initially it took a little time to compile them all (about 80) with reshacker...but maintaining them is a breeze. You can call a batch from the command line (windows) to automate this task if you have many to do...but it took a little brain work (not too much though :)). To add an icon is as simple as creating it in acad, save it somewhere and add resource by browsing to the saved bmp.

Thanks for your input Jeff. I will test out your previous post tomorrow when I get back to work.



Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sinc

  • Guest
Successful If statement prompt
« Reply #18 on: March 23, 2005, 12:48:20 PM »
Quote from: Jeff_M

sinc,
Although there is great advice here, I must advise ronjonp that it's not all exactly correct. The biggest thing is that acad.lsp does, in fact, affect the first opened drawing (provided ACADLSPASDOC is set to 0) only, so any drawing specific variables will only be good for that first drawing. However, if you add a (command "undefine" "whatever"), that command will get undefined for the entire editing session, no matter which drawing you are in.


D'Oh!  You're right of course.  I was mixing up application namespaces with what I was saying.  That's what I get for doing a fast-and-dirty post on my way to a meeting...

Quote from: Jeff_M

Next, I place ALL of my setup type & customization stuff in my own .lsp file that I call from mymenu.mnl. I do it this way so that when I upgrade or even just reinstall I know what I need to add to the new install to be back up and running in a minimal amount of time. All I have to do is menuload mymenu once and it will be loaded from then on out......plus I don't need to worry about the acad.lsp or acaddoc.lsp files being overwritten or duplicated by others.

And as I said in my reply to ronjonp in that other thread, I used to have problems with the StartUpSuite. More often than not I would not have my custom routines loaded. That was the big driving force for me to place all of my startup apps in the mnl file.....voila', no more problems ;)


I see no real problem with this approach.  The only thing to keep in mind is that your custom routines will only be loaded with your special menu.  If this is the way you want it, then that's fine.  But if there are other users on your system, they will not be able use the custom commands unless they load your menu.  Putting "load" commands in acaddoc.lsp makes them available to all users on the system (depending on user path settings and which directory you place it in, of course).

Some Land Desktop, Civil, and Surveying commands (or at least portions of them) are loaded in mnl files.  These features are not available if you create a user profile that does not load the appropriate menu.  Careful thought here can help you if you want to create "special profiles" that don't load so much stuff on startup, but instead are tailored to specific tasks.  This is "customization overkill" for most people (IMHO), but very useful for some.  Something to keep in mind.

The only big thing (going back to what ronjump was talking about) is that if you create a custom setup lisp file like that and explicitely load it from your mnl file, it should have it's own name, and should not be called "acad.lsp" or "acaddoc.lsp".  These filenames are reserved for special use by Autocad, and Autocad automatically looks for and loads them if found.

As to why your startup suite wasn't working when called from acaddoc.lsp, there could be a number of reasons...  Answer is it SHOULD work, unless you are doing something wrong/inappropriately.  This initialization takes place BEFORE drawing initialization is complete.  Therefore you CANNOT do things like "undefine" here.  You should also not create or delete entities here.  Things that require a fullly-initialized drawing should be put in the STARTUP function as specified in the documentation.

I don't really feel your argument about loading in the MNL as protection against "bad users" holds any water.  If some other user is going to get on your system and screw up the configuration because they don't know what they're doing, well, there isn't a whole lot you can do about that...  A sufficiently-tenacious "bad user" can screw up pretty much anything.  However, loading your custom Lisp in your MNL file because you like it that way and it seems to work best for you, well, that's a valid reason.

ronjonp

  • Needs a day job
  • Posts: 7529
Successful If statement prompt
« Reply #19 on: March 23, 2005, 01:30:10 PM »
Jeff,

Here is the results:

Code: [Select]
Command: (findfile "acaddoc.lsp")
"C:\\Documents and Settings\\rperez\\Application Data\\Autodesk\\AutoCAD
2005\\R16.1\\enu\\support\\acaddoc.lsp"

Command: (findfile "acad.lsp")
"C:\\PROGRA~1\\CADET2~1\\acad.lsp"


I do have multiple acad.lsp files DOH!

I definitely agree with the loading/running custom lisp from the *.mnl file...it has been the easiest way for me so far.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CADaver

  • Guest
Successful If statement prompt
« Reply #20 on: March 23, 2005, 02:11:26 PM »
Quote from: ronjonp
I definitely agree with the loading/running custom lisp from the *.mnl file...it has been the easiest way for me so far.
Ron


Gotta agree with that, for us.  I customize several MNL's, One for the base menu (usually ACAD.mnl) to which I add a call to load a specific autoloader lisp function.  Then another MNL with the client specific menu to load client specific function.  Another with discipline specific menu and functions, finally a personal menu with it's own mnl.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Successful If statement prompt
« Reply #21 on: March 23, 2005, 02:17:34 PM »
Quote from: sinc

The only big thing (going back to what ronjump was talking about) is that if you create a custom setup lisp file like that and explicitely load it from your mnl file, it should have it's own name, and should not be called "acad.lsp" or "acaddoc.lsp".  These filenames are reserved for special use by Autocad, and Autocad automatically looks for and loads them if found.

As to why your startup suite wasn't working when called from acaddoc.lsp, there could be a number of reasons...  Answer is it SHOULD work, unless you are doing something wrong/inappropriately.  This initialization takes place BEFORE drawing initialization is complete.  Therefore you CANNOT do things like "undefine" here.  You should also not create or delete entities here.  Things that require a fullly-initialized drawing should be put in the STARTUP function as specified in the documentation.

Granted, acad.lsp and acaddoc.lsp are loaded if found, but they are not reserved for use by Autocad. On the other hand, acadxxxx.lsp and acadxxxxdoc.lsp are reserved. The former are for User's use, as shown in this Load Order table found in the help file:
    You can understand the effects that one file may have on another if you know the order in which files are loaded when you start the software. For example, you have defined a function in an AutoLISP® routine that is loaded from the acad.lsp file, but the function does not work when you start AutoCAD®. This occurs because the function has been redefined by the acaddoc.lsp file, which is loaded after acad.lsp.

    Solution

    Following is a list of AutoCAD, Express Tools, and user-defined files in the order they are loaded when you first start the program.

    File                   For use by:
     
    acad2000.lsp     AutoCAD
     
    acad.rx             User
     
    acad.lsp             User
     
    acad2000doc.lsp  AutoCAD
     
    acetutil.fas        Express Tools
     
    acaddoc.lsp       User
     
    mymenu.mnc    User
     
    mymenu.mnl     User
     
    acad.mnc          AutoCAD
     
    acad.mnl           AutoCAD
     
    acetmain.mnc    Express Tools
     
    acetmain.mnl     Express Tools
     
    s::startup          User
     [/list:u]

    I didn't say I was calling a startup suite from acaddoc.lsp.....it was things placed into the Startup Suite in the Appload function that didn't always load. That was why I made my own "startup" lisp that autoloads with my mnl. Oh, and my actual personalized menu only contains my custom toolbars. This way I can alter the stock Acad toolbars and not worry about acad overwriting those mods.

    And again, you CAN use "undefine" in the acad.lsp & acaddoc.lsp. I did it for years prior to converting over to the menu.mnl (and tested it yesterday to see if it still behaved this way).

ronjonp

  • Needs a day job
  • Posts: 7529
Successful If statement prompt
« Reply #22 on: March 23, 2005, 06:20:41 PM »
Quote
Gotta agree with that, for us


Cadaver,

You feelin alright? You agreed with me...  :lol:  :lol:

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC