Author Topic: Loading Routine Automatically  (Read 2073 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 465
Loading Routine Automatically
« on: January 06, 2011, 07:26:25 PM »
Instead of adding a line in acad2011doc.lsp, how to write a little code to load routine automatically when opening a drawing or starting a new drawing?
Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Loading Routine Automatically
« Reply #1 on: January 06, 2011, 07:36:25 PM »
Don't alter the ACAD20XXDOC.lsp! Those aren't to be messed with!

Have a read of this:

http://lee-mac.com/autoloading.html

MeasureUp

  • Bull Frog
  • Posts: 465
Re: Loading Routine Automatically
« Reply #2 on: January 06, 2011, 08:47:05 PM »
Don't alter the ACAD20XXDOC.lsp! Those aren't to be messed with!

Have a read of this:

http://lee-mac.com/autoloading.html
Thanks, I will add my autoload functions in a new file of AcadDoc.lsp.

I'd like to change this topic by another question:
Based on the code below, I don't want it load "mylisp.lsp" every time "TEST" is executed. how to write a conditional statement to provent loading a routine again if it has been loaded?
Code: [Select]
(defun c:TEST ()
(load "MyLISP.lsp" "MyLISP Failed to Load.")
... main functions here
)
Thanks again.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Loading Routine Automatically
« Reply #3 on: January 06, 2011, 09:27:15 PM »
Here is how I load my routines "Arch Program":
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Following is a list of AutoCAD, Express Tools, and user-defined files in
;;; the order they are loaded when you first start the program. Go to AutoCAD
;;; Help and search for "support file loading" (including quotes) and the
;;; top result is "Order of support file loading" which nets the following:
;;;      <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
;;; Note: If the user-defined function S::STARTUP is included in the acad.lsp or
;;; acaddoc.lsp file or a MNL file, the function is called when you enter a new
;;; drawing or open an existing drawing. Thus, you can include a definition of
;;; S::STARTUP in the LISP startup file to perform any setup operations. For more
;;; information about the s::startup function, refer to the Customization Guide.
;;;
;;; It should be noted that Autodesk's website is misleading about the load order.
;;; The menus load in the order they were initially loaded in, and *not* always
;;; the user menu first. The only way the user menu loads first is if all menus
;;; were removed and the user's menu was loaded first, then the other menus
;;; subsequently. In most cases people tend to leave Acad's menu there, then
;;; Express Tools (if installed), and then finally the user's menu.
;;; This can be verified by watching the menu load prompts:
;;; AutoCAD menu utilities loaded.
;;;
;;; Key files to needed to run this program:
;;; (1.) The "ACAD.lsp" file sets the path for the arch program along with the saved autocad
;;;     environment settings for a clean restore to generic autocad when the arch program
;;;     is unloaded. This is the only file that must be located at each workstation within
;;;     the autocad support directory. It only loads at AutoCAD startup.
;;; (2.) The "ACADDOC.lsp" loads the "ARCH_INITIALIZE.fas" file.
;;; (3.) The "ARCH_INITIALIZE.fas" initialize the setup.
;;; (4.) Custom settings are controled by the "custom_xxx.lsp" file.
;;; (5.) The "ARCH.mnc" loads the "ARCH.mnl" file automatically which contains many
;;;     misc functions required to operate this program.
;;; (6.) The "ARCH_SUBROUTINES.fas" contains all of the subfunctions.
;;; (7.) All bitmaps for the toolbars are compiled in the "ARCH.dll" which is loaded
;;;     automatically.
;;; (8.) The "ARCH.dcl" file must be located in the acad support file search path
;;;     it contains all of the dialog box widgets for the arch program.
;;;     @include "..\\ARCH.dcl"
;;;
;;;
;;; General Rule is to NOT edit the acad200Xdoc.lsp file because it is an Autocad file
;;; that CAN and WILL be replaced if you install patches. I would suggest using the
;;; acaddoc.lsp for the code. 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:    
;;; acad200X.lsp AutoCAD    
;;; acad.rx         User    
;;; acad.lsp User    
;;; acad200Xdoc.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
;;;
;;; To make sure you are pulling the correct acaddoc.lsp copy and paste the following
;;; line to the command line (findfile "acaddoc.lsp") You should get the path returned
;;; and if it is not where you think the file is installed you have more than one file.
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Lee Mac

  • Seagull
  • Posts: 12925
  • London, England
Re: Loading Routine Automatically
« Reply #4 on: January 07, 2011, 08:20:23 AM »
You could test one of the functions defined in MyLISP to see whether a value has been bound to the symbol defining it:

Code: [Select]
(defun c:test ( )

  (if (not c:MySyntax)
    (load "MyLISP.lsp" "MyLISP Failed to Load")
  )

  ...
)

Or, I think autoload will also accomplish what you want to achieve.