See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: How autoload subroutines code

  1. #1
    Login to Give a bone
    0

    Default How autoload subroutines code

    Goodnight. I would like to know how to load subroutines that I have in a directory, so that they only load when executing their command. The initial code is the following:

    [COLOR=#666666][FONT=Artifakt];loads all needed subroutines
    Code:
    (vl-load-com)
    (if (findfile ".\\Subrutinas\\LeeMac")
    (mapcar '(lambda (x)
    (if (wcmatch (strcase x) "*.LSP")
    (load
    (strcat (findfile ".\\Subrutinas\\LeeMac") "\\" x)
    ) ;_load
    ) ;_ if
    ) ;_ lambda
    (vl-directory-files
    (findfile ".\\Subrutinas\\LeeMac")
    ) ;_ vl-directory-files
    ) ;_ mapcar
    ) ;_ if


    I tried to change "load" for "autoload", but it does not work. In leemac folder y have three files .lsp.

    StrikethroughV1-1.lsp define "strike", "strike2", "strike3", "under", "under2", "overunder2"
    cajaenvolvente(minboundingbox).lsp load minboundingbox.lsp.
    Attached Images Attached Images
    • File Type: jpg 1.jpg (30.2 KB, 25 views)
    • File Type: jpg 2.jpg (38.8 KB, 24 views)
    Last edited by rkmcswain; 2019-03-25 at 12:57 PM. Reason: added [CODE] tags

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,145
    Login to Give a bone
    0

    Default Re: How autoload subroutines code

    Quote Originally Posted by marco_antonio-77339780 View Post
    Goodnight. I would like to know how to load subroutines that I have in a directory, so that they only load when executing their command. The initial code is the following:
    You need to Wrap Code tags around any code you post so it will display correctly on the page like your attached image. That makes it easy for us to read, test, and modify for you if needed.
    Clicking the [Go Advanced] button at the bottom puts a toolbar at the top and the # icon in that toolbar places code tags around selected text for you or simply paste your code inside.

    That looks like a lot of work just to load a lisp file. First I'd put the folders where you keep your code in the Support and Trusted paths, then add
    Code:
    (load "LM:boundingbox")
    as the second line of code assuming that's the name of the lisp file it's defined in.
    Do you really keep all your customization on a flash drive (USB-01)?
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  3. #3
    Login to Give a bone
    0

    Default Re: How autoload subroutines code

    Code:
    ;loads all needed subroutines
    (vl-load-com)
    (if (findfile ".\\Subrutinas\\LeeMac")
      (mapcar '(lambda (x)
                 (if (wcmatch (strcase x) "*.LSP")
                   (load
                     (strcat (findfile ".\\Subrutinas\\LeeMac") "\\" x)
                   ) ;_load
                 ) ;_ if
               ) ;_ lambda
              (vl-directory-files
                (findfile ".\\Subrutinas\\LeeMac")
              ) ;_ vl-directory-files
      ) ;_ mapcar
    ) ;_ if
    - - - Updated - - -

    Yes, I work in this way because I always work on many different pc's.

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,148
    Login to Give a bone
    1

    Default Re: How autoload subroutines code

    As Tom mentioned, it's best to have your lisp routines in a "support path" and in a "trusted path", preferably outside your AutoCAD support files, like C:\MYLISPS
    As well as an acaddoc.lsp (a file you create) which sets variables and loads routines, as well as ones loading when invoked by their commands.

    Maybe you can add your jump drive\folders to those paths when you start working on each machine, not sure how it works when you unplug it though?

    Sample of a basic "acaddoc.lsp"
    Code:
    (defun-q MYSTARTUP ()
     	(SETVAR "OSMODE" 703) ;;variables set when opening each drawing
    	(SETVAR "REGENMODE" 1)
    	(SETVAR "GRIDMODE" 0)
    	(SETVAR "SNAPMODE" 0)
    	(SETVAR "LIMCHECK" 0) ;; and so on 
    	(PRINC)
    
    (LOAD "FAVORITE LISP") ;; loads lisp routines every time (need to be in support and trusted paths)
    (LOAD "ANOTHER FAVORITE LISP")
    
    ;;LISP ROUTINES INVOKED BY THIER COMMANDS
    
    (AUTOLOAD "STL" '("STL")) ;;;STEEL SHAPES, COMMAND: STL
    (AUTOLOAD "WELD" '("WLD")) ;;;WELD SYMBOLS, COMMAND WLD
    
    (setq S::STARTUP (append S::STARTUP MYSTARTUP))
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,145
    Login to Give a bone
    1

    Default Re: How autoload subroutines code

    About Saving Program Settings as Profiles
    https://knowledge.autodesk.com/suppo...8F729-htm.html
    Tom Beauford P.S.M. - Civil 2019 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  6. #6
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,148
    Login to Give a bone
    0

    Default Re: How autoload subroutines code

    Quote Originally Posted by Tom Beauford View Post
    About Saving Program Settings as Profiles
    https://knowledge.autodesk.com/suppo...8F729-htm.html
    Good info Tom! thanks
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

  7. #7
    Login to Give a bone
    0

    Default Re: How autoload subroutines code

    Hello, according to what I understand now I have my lisp in C:\MYLISP (see jpg's). I have written autoload code for my lisp in the same directory that "ACADDOC.LSP". I would like change the load function of my subroutines (at the beginning of all the code of ACADDOC.LSP) by a autoload function that load my subroutines only if I call his command.
    In LeeMAC folder I have three lisps: cajaenvolvente(minboundingbox).lsp, minboundingbox.lsp, StrikethroughV1-1.lsp.

    cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
    StrikethroughV1-1.lsp call to "STRIKE", "STRIKE2", "STRIKE3", "UNDER", "UNDER2", "OVERUNDER2"
    Attached Images Attached Images
    Last edited by marco_antonio-77339780; 2019-03-25 at 02:39 PM.

  8. #8
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,148
    Login to Give a bone
    0

    Default Re: How autoload subroutines code

    Quote Originally Posted by marco_antonio-77339780 View Post
    Hello, according to what I understand now I have my lisp in C:\MYLISP (see jpg's). I have written autoload code for my lisp in the same directory that "ACADDOC.LSP". I would like change the load function of my subroutines (at the beginning of all the code of ACADDOC.LSP) by a autoload function that load my subroutines only if I call his command.
    In LeeMAC folder I have three lisps: cajaenvolvente(minboundingbox).lsp, minboundingbox.lsp, StrikethroughV1-1.lsp.

    cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
    StrikethroughV1-1.lsp call to "STRIKE", "STRIKE2", "STRIKE3", "UNDER", "UNDER2", "OVERUNDER2"
    I don't know anything about the lisp routines you're using, or what the loading code you have is doing, (is that working for you?).

    I am confused about this:
    cajaenvolvente(minboundingbox).lsp call to LM:minboundingbox (in minboundingbox.lsp).
    How is one lisp routine calling out the other? Is there a command

    But, to use multiple commands to "AUTOLOAD" a routine (your bottom example) would look like this:
    Code:
    (AUTOLOAD "StrikethroughV1-1" '("STRIKE" "STRIKE2" "STRIKE3" "UNDER2" "OVERUNDER2"))
    Assuming this and all supporting files are in your file support and trusted paths:
    Attached Images Attached Images
    Ted
    ____________________________________________________________________ ________________
    Windows 7 Professional
    AutoCAD 2017 - REVIT 2017 - Inventor Professional 2015 (when I can)

Similar Threads

  1. AutoLoad?
    By m.mason in forum AutoLISP
    Replies: 7
    Last Post: 2009-11-02, 11:12 AM
  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
  •