Results 1 to 8 of 8

Thread: AutoLoad?

  1. #1
    Member
    Join Date
    2008-06
    Location
    Texas
    Posts
    4
    Login to Give a bone
    0

    Default AutoLoad?

    Does anybody know what's going on here? I thought this was supposed to work!

    Code:
    (setq LispFolder "C:\\mlm_DEV\\") 
    (if (findfile (strcat LispFolder "FE_EraseBlankText.lsp")) 
      (autoload (strcat LispFolder "FE_EraseBlankText") '("EBT")) 
    )
    According to HELP, autoload will use the current search paths if filepath is not specified. Apparently, even if a filepath IS specified, it will still only use current search paths. Ot at least the pathname thingy isn't working right (anymore)?

    I thought this worked once upon a time...

  2. #2
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: AutoLoad?

    Add the .LSP extension to the AUTOLOAD function call. It seems that if you specify a path, you have to specify the entire filename as well.

    Usually (if the LSP is in the search paths) you just call autoload with the filename (excluding extension). This then searches the paths for any files with that name & VLX, FAS, LSP, etc. extensions.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  3. #3
    Member
    Join Date
    2008-06
    Location
    Texas
    Posts
    4
    Login to Give a bone
    0

    Default Re: AutoLoad?

    Well, as suspected, it turns out the autoload routine is not designed to handle a filepath. In fact, it actually attempts to strip out the slashes in the filename. (spotted by Jeff_M @ theSwamp)

    So, short of modifying the autoload routines (in ACAD20XXDOC.lsp) one could double up on their filepath slashes as such:
    "C:\\\\mlm_DEV\\\\"
    I haven't tested it yet, but it looks like it would work...

  4. #4
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: AutoLoad?

    Now I really don't know???? What version of ACad? Checked the ACADDOC2008.LSP file (Vanilla 2008 ), here's the relevant extracts:
    Code:
    (defun _autoqload (quoi app cmdliste / qapp symnam)
      (setq qapp (strcat "\"" app "\""))
      (setq initstring "\nInitializing...")
      (mapcar
       '(lambda (cmd / nom_cmd)
          (progn
            (setq nom_cmd (strcat "C:" cmd))
            (if (not (eval (read nom_cmd)))
                (eval
                 (read (strcat
                        "(defun " nom_cmd "( / rtn)"
                        "(setq m:err *error* *error* *merrmsg*)"
                        "(if (ai_ffile " qapp ")"
                        "(progn (princ initstring)"
                        "(_auto" quoi "load " qapp ") (setq rtn (" nom_cmd ")))"
                        "(ai_nofile " qapp "))"
                        "(setq *error* m:err m:err nil)"
                        "rtn)"
                        ))))))
       cmdliste)
      nil
    )
    
    (defun autoload (app cmdliste)
      (_autoqload "" app cmdliste)
    )
    
    (defun _autoload (app)
    ; (princ "Auto:(load ") (princ app) (princ ")") (terpri)
      (load app)
    )
    
    (defun ai_ffile (app)
      (or (findfile (strcat app ".lsp"))
          (findfile (strcat app ".exp"))
          (findfile (strcat app ".exe"))
          (findfile (strcat app ".arx"))
          (findfile app)
      )
    )
    
    (defun ai_nofile (filename)
      (princ
        (strcat "\nThe file "
                filename
                "(.lsp/.exe/.arx) was not found in your search path folders."
        )
      )
      (princ "\nCheck the installation of the support files and try again.")
      (princ)
    )
    Nowhere can I find anything trying to remove "\\" from the filename. And BTW, looking at the code it seems that it shouldn't be necessary to add an extension.

    However, my comment previously was in error ... it searches for .LSP, .EXP, .EXE, .ARX, and then whatever you've specified yourself. This may be why I "thought" it needed an extension if pathed ... I usually compile my final apps to VLX of FAS, then had to give those extensions explicitly to autoload ... now I know why!

    If you do have something strange happening in your ACADDOC20##.LSP, you shouldn't modify it. Rather just redefine the offending function just before you call autoload. You could even save to orriginal to a new name and revert it back after you've finished ... now that would be "good" programming practise!
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  5. #5
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Hartford, Michigan
    Posts
    3,194
    Login to Give a bone
    0

    Default Re: AutoLoad?

    the way I've always done it was
    Code:
    (autoload "mylisp.lsp" '("call"))
    where the folder that mylisp.lsp is located in is in the AutoCAD support files search path.

    I wouldnt recommend modifying AutoDesk's files, if they send out an update, you could risk loosing your modifications.
    Christopher T. Cowgill, P.E.
    Autodesk Expert Elite
    AEC Collection Civil 3D 2020
    Windows 10

  6. #6
    Member
    Join Date
    2005-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: AutoLoad?

    My English is not very well, but I will try to ask you the following:
    I have two questions:

    1) Autoload is defined in Acaddoc2008.lsp (for Autocad 2008 for example) and as internal command in Autolisp (see help). When I call (autoload "Mylisp" '("MyCommand")) what autoload runs?

    2) I used autoload whit a VLX file and it was loaded.
    When I open a drawing the command is available. I type at the command line "MyCommand" and the command runs. When I open my second drawing and I type at the command line "MyCommand" appears the following error message:

    Initializing...LISP application is already loaded Mylisp

    Why?

  7. #7
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: AutoLoad?

    Quote Originally Posted by makitoxx66 View Post
    1) Autoload is defined in Acaddoc2008.lsp (for Autocad 2008 for example) and as internal command in Autolisp (see help). When I call (autoload "Mylisp" '("MyCommand")) what autoload runs?
    That is the "internal" command. So if you override that one, you won't have any autoload anymore. Please see some of the previous posts. Do not edit the ACADDOC2008.LSP file, it's one of ADesk's own files and (as you can see) defines some functions which won't work if you override / delete them. You could add to the file, but again as it's ADesk's file an update could overwrite your additions to the file. Therefore add all your code (which you wanted in ACADDOC2008.LSP) into an ACADDOC.LSP file. If such doesn't exist create one, that's what it's meant for: user customization.

    Quote Originally Posted by makitoxx66 View Post
    2) I used autoload whit a VLX file and it was loaded.
    When I open a drawing the command is available. I type at the command line "MyCommand" and the command runs. When I open my second drawing and I type at the command line "MyCommand" appears the following error message:

    Initializing...LISP application is already loaded Mylisp

    Why?
    Not entirely sure, I think your VLX is maybe loading into a separate memory space. Thus it works more like an ARX file ... a "normal" VLA or LSP file loads into the DWG's memory ... therefore it needs to be loaded once per drawing.

    If you're using a VLX set to a separate namespace, you could simply load it from ACAD.LSP instead - so it loads only once per ACad session. There's a workaround if you don't want to follow the ACAD.LSP route and still use the autoload: use the VLX using a vl-load-all function. You may fiddle around with various options of having specialized "autoload" functions for this type of purpose. But it's just oo much hassle ... just change the AutoLoad to a normal Load.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  8. #8
    Member
    Join Date
    2005-10
    Posts
    8
    Login to Give a bone
    0

    Default Re: AutoLoad?

    Quote Originally Posted by irneb View Post
    That is the "internal" command. So if you override that one, you won't have any autoload anymore. Please see some of the previous posts. Do not edit the ACADDOC2008.LSP file, it's one of ADesk's own files and (as you can see) defines some functions which won't work if you override / delete them. You could add to the file, but again as it's ADesk's file an update could overwrite your additions to the file. Therefore add all your code (which you wanted in ACADDOC2008.LSP) into an ACADDOC.LSP file. If such doesn't exist create one, that's what it's meant for: user customization.

    Not entirely sure, I think your VLX is maybe loading into a separate memory space. Thus it works more like an ARX file ... a "normal" VLA or LSP file loads into the DWG's memory ... therefore it needs to be loaded once per drawing.

    If you're using a VLX set to a separate namespace, you could simply load it from ACAD.LSP instead - so it loads only once per ACad session. There's a workaround if you don't want to follow the ACAD.LSP route and still use the autoload: use the VLX using a vl-load-all function. You may fiddle around with various options of having specialized "autoload" functions for this type of purpose. But it's just oo much hassle ... just change the AutoLoad to a normal Load.
    Thanks, I know that: the Acaddoc2008.lsp is ADesk's own files. If I upgrade the version ao AutoCad this file is erased. I did not know what autoload command run. Now I know it.

    I'll try whit acad.lsp instead acaddoc.lsp. My VLX is set to a separate namespace. And but I will return to the manual method of (load "MyProgram.VLX"). Thank

Similar Threads

  1. Autoload diractory with many LSP files
    By marko_ribar in forum AutoLISP
    Replies: 9
    Last Post: 2010-11-15, 01:28 PM
  2. Autoload in VBA Manager
    By scott.ferguson.99233 in forum VBA/COM Interop
    Replies: 3
    Last Post: 2005-11-11, 06:33 AM
  3. AutoLoad/Run AutoLISP
    By ironwood1957 in forum AutoLISP
    Replies: 5
    Last Post: 2005-03-11, 06:22 PM
  4. AutoLOAD? From where?
    By methost in forum AutoCAD General
    Replies: 5
    Last Post: 2005-02-01, 08:10 PM
  5. autoload menu
    By IanR in forum VBA/COM Interop
    Replies: 5
    Last Post: 2004-07-16, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •