Author Topic: Question about Load lisp with *.mnl  (Read 6219 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #15 on: April 27, 2014, 04:18:22 PM »
ok ,
Code - Auto/Visual Lisp: [Select]
  1. (setq filenameL (vl-directory-files "C:\\topocad" "*.lsp"))
  2. (foreach x filenameL
  3.   (load x)
  4.   )
  5.  

if i understand now i have to change this "*.lsp" to
Code - Auto/Visual Lisp: [Select]
  1. (setq filenameL (vl-directory-files "C:\\topocad" "test1.lsp" "test2.lsp" "test3.fas" "test4.vlx" ))

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #16 on: April 27, 2014, 04:49:20 PM »
i put this lines in a txt file and name it to acaddoc.lsp

Code - Auto/Visual Lisp: [Select]
  1. (setq filenameL (vl-directory-files "C:\\topocad" "*.lsp"))
  2. (foreach x filenameL
  3.   (load x)
  4.   )

When i paste this file in C:\topocad file  my autocad not opening !!! why?

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Question about Load lisp with *.mnl
« Reply #17 on: April 27, 2014, 05:31:55 PM »
I would suggest:
Code: [Select]
(defun load-all-in-folder ( dir )
    (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
    (foreach lsp (vl-directory-files dir "*.lsp" 1)
        (load (strcat dir "\\" lsp) nil)
    )
    (princ)
)
Code: [Select]
(load-all-in-folder "C:\\topocad")
This recent thread may also be helpful: Load all LISP files in folders & subfolders.

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #18 on: April 27, 2014, 06:12:26 PM »
Thank you lee

if i undersant

Code - Auto/Visual Lisp: [Select]
  1. (load-all-in-folder "C:\\topocad")
  2.  (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
  3.     (foreach lsp (vl-directory-files dir "*.lsp" 1)
  4.         (load (strcat dir "\\" lsp) nil)
  5.     )
  6.     (princ)
  7. )
  8.  

 acaddoc.lsp

I try it load all the lisp files , don't load *.vlx files

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Question about Load lisp with *.mnl
« Reply #19 on: April 27, 2014, 06:25:01 PM »
No, you first need to define the function (the defun expression) and then call it with the required argument(s) (the load-all-in-folder expression with the given directory).

To include VLX / FAS, add the following to your acaddoc.lsp:
Code - Auto/Visual Lisp: [Select]
  1. (defun load-all-in-folder ( dir )
  2.     (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
  3.     (foreach app
  4.         (apply 'append
  5.             (mapcar
  6.                 (function
  7.                     (lambda ( ext )
  8.                         (vl-directory-files dir ext 1)
  9.                     )
  10.                 )
  11.                '("*.vlx" "*.fas" "*.lsp")
  12.             )
  13.         )
  14.         (eval
  15.             (load
  16.                 (strcat dir "\\" app)
  17.                 (quote (princ (strcat "\nUnable to load " app)))
  18.             )
  19.         )
  20.     )
  21.     (princ)
  22. )
  23. (load-all-in-folder "C:\\topocad")

EDIT: Updated.

EDIT: Actually, this is better:

Code - Auto/Visual Lisp: [Select]
  1. (defun load-all-in-folder ( dir )
  2.     (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
  3.     (foreach ext '("*.vlx" "*.fas" "*.lsp")
  4.         (foreach app (vl-directory-files dir ext 1)
  5.             (eval (load (strcat dir "\\" app) '(princ (strcat "\nUnable to load " app))))
  6.         )
  7.     )
  8.     (princ)
  9. )
  10. (load-all-in-folder "C:\\topocad")
« Last Edit: April 27, 2014, 06:31:10 PM by Lee Mac »

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #20 on: April 27, 2014, 06:38:26 PM »
Code: [Select]
(defun load-all-in-folder ( dir )
    (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
    (foreach ext '("*.vlx" "*.fas" "*.lsp")
        (foreach app (vl-directory-files dir ext 1)
            (eval (load (strcat dir "\\" app) '(princ (strcat "\nUnable to load " app))))
        )
    )
    (princ)
)
(load-all-in-folder "C:\\topocad")

I have an autocad load problem with this code

And with this two codes can not load *.vlx files
« Last Edit: April 27, 2014, 06:42:45 PM by Topographer »

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Question about Load lisp with *.mnl
« Reply #21 on: April 27, 2014, 07:10:57 PM »
Lee you are a very patient man.... :laugh:

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #22 on: April 27, 2014, 07:31:08 PM »
in vlisp editor this code works

Code - Auto/Visual Lisp: [Select]
  1. (defun load-all-in-folder ( dir )
  2.     (setq dir (vl-string-right-trim "\\" (vl-string-translate "/" "\\" dir)))
  3.     (foreach ext '("*.vlx" "*.fas" "*.lsp")
  4.         (foreach app (vl-directory-files dir ext 1)
  5.             (eval (load (strcat dir "\\" app) '(princ (strcat "\nUnable to load " app))))
  6.         )
  7.     )
  8.     (princ)
  9. )
  10. (load-all-in-folder "C:\\topocad")
  11.  

How can i load it any time at start up? If i give him a name acaddoc.lsp my autocad didin't load

pedroantonio

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #23 on: April 27, 2014, 07:36:13 PM »
I add t in my *.mnl file and works . I will test more.

Thanks

RC

  • Guest
Re: Question about Load lisp with *.mnl
« Reply #24 on: April 27, 2014, 08:26:12 PM »
As an option investigate AUTOLOAD

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Question about Load lisp with *.mnl
« Reply #25 on: April 28, 2014, 07:06:34 AM »
I add t in my *.mnl file and works . I will test more.

Thanks

Pedro, as we where kind enough to post possible solutions for you to use, please post your final solution here.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Question about Load lisp with *.mnl
« Reply #26 on: April 28, 2014, 06:15:28 PM »
Lee you are a very patient man.... :laugh:

I try my best  :-)

How can i load it any time at start up? If i give him a name acaddoc.lsp my autocad didin't load

I would recommend first verifying that your acaddoc.lsp is loading successfully -
Add a simple princ call to the very top of your acaddoc.lsp, e.g.:

Code: [Select]
(princ "\nacaddoc.lsp loaded.")
Then check that this message appears at the command-line when a drawing is opened.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Question about Load lisp with *.mnl
« Reply #27 on: April 29, 2014, 03:31:49 AM »
Are you using ACadDoc.LSP or an MNL file?

If the ACadDoc.LSP is it on your support folder paths? What happens if you type this at the command prompt?
Code: [Select]
(findfile "acaddoc.lsp")If nil, the AutoCad can't find it, if it's shown in another folder, then you have 2 or more of them - AutoCAD only loads the 1st one it finds.

If the MNL is the accompanying CUI loaded? Are they both in the same folder and named the same?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.