Author Topic: Helo me autoload lisp after modify  (Read 2974 times)

0 Members and 1 Guest are viewing this topic.

vnanhvu

  • Guest
Helo me autoload lisp after modify
« on: February 26, 2014, 04:09:55 AM »
Hi all !
I use 10 file Lisp. I appload them with remember history.

When i modify 1 file Lisp. How can you write a command to automatic reload this file lisp without use appload/content/remove. ( Only 1 command for update file Lisp ).

Thank you !

bilançikur

  • Newt
  • Posts: 82
Re: Helo me autoload lisp after modify
« Reply #1 on: February 26, 2014, 04:59:42 AM »
Maybe you can use AlanJT's code from over here:
http://forums.augi.com/showthread.php?101676-A-routine-that-loads-all-of-my-other-routines&p=977383&viewfull=1#post977383

Create your own function to quickly load (and thus reload) all lisp files in a dedicated folder.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Helo me autoload lisp after modify
« Reply #2 on: February 26, 2014, 08:29:40 AM »
Are you using AutoCAD ?

Use VLIDE to edit and reload...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Helo me autoload lisp after modify
« Reply #3 on: February 26, 2014, 08:44:29 AM »
I'm always surprised when people don't use VLIDE.
It isn't the best editor but for debugging it can't be beat.
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.

bilançikur

  • Newt
  • Posts: 82
Re: Helo me autoload lisp after modify
« Reply #4 on: February 26, 2014, 09:01:02 AM »
VLIDE would be the first choice, of course. But I have forgot about that because we use ZWCAD these days.
So always when I am editing lisp, I use NotePad++, hit ctrl+S to save and then switch bac to Cad and invoke the command to load all lisp in that folder.

ChrisCarlson

  • Guest
Re: Helo me autoload lisp after modify
« Reply #5 on: February 26, 2014, 11:56:09 AM »
I could never get the hang of VLIDE, that lisp is genius though thanks for the suggestion.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Helo me autoload lisp after modify
« Reply #6 on: March 02, 2014, 03:10:09 AM »
Is this a good solution?
Creating an intermediate lisp, So each time run the lisp will be loaded.
Code: [Select]
(defun c:lsp1  () (load "C:/Lisp/lsp1.lsp")  (c:/lsp1)  (princ))
(defun c:lsp2  () (load "C:/Lisp/lsp2.lsp")  (c:/lsp2)  (princ))
(defun c:lsp2  () (load "C:/Lisp/lsp3.lsp")  (c:/lsp3)  (princ))
...
« Last Edit: March 02, 2014, 05:17:48 AM by HasanCAD »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Helo me autoload lisp after modify
« Reply #7 on: March 02, 2014, 04:05:11 AM »
HasanCaD,

Your method is great for the initial load of a routine, I won't work to re-load a revised file though because the command definition will point to the currently loaded code.

I don't think you meant to have the forwardSlash in the command name ?? 

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Helo me autoload lisp after modify
« Reply #8 on: March 02, 2014, 07:45:58 AM »
How about the drag and drop method, drag the lisp file into the current cad window, it should reload...

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Helo me autoload lisp after modify
« Reply #9 on: March 02, 2014, 08:46:34 AM »
Here is another idea:

Code: [Select]
(defun load-if-modified ( lsp sym / itm )
    (if (setq lsp (findfile lsp))
        (progn
            (if (and (eval sym) (setq itm (assoc (strcase lsp) load-if-modified:data)))
                (if (equal (cdr itm) (vl-file-systime lsp))
                    (prompt "\nFile not modified.")
                    (progn
                        (prompt "\nFile modified - reloading...")
                        (setq load-if-modified:data
                            (subst
                                (cons (strcase lsp) (vl-file-systime lsp))
                                itm
                                load-if-modified:data
                            )
                        )
                        (load lsp nil)
                    )
                )
                (progn
                    (setq load-if-modified:data
                        (cons
                            (cons (strcase lsp) (vl-file-systime lsp))
                            load-if-modified:data
                        )
                    )
                    (prompt "\nFirst-time loading.")
                    (load lsp nil)
                )
            )
            (if (eval sym)
                ((eval sym))
                (prompt "\nFile not loaded or symbol not defined.")
            )
        )
        (prompt "\nFile not found.")
    )
    (princ)
)

Call with the LISP filename & command symbol, e.g.:

Code: [Select]
(load-if-modified "MyLISP.lsp" 'c:mycommand)