Author Topic: I need some advice..please? AutoLoad & Run a lisp?  (Read 2836 times)

0 Members and 1 Guest are viewing this topic.

TomREd

  • Guest
I need some advice..please? AutoLoad & Run a lisp?
« on: November 09, 2006, 09:32:16 AM »
I'm curious, can I make AutoCAD run the LFD.lsp everytime I open a drawing. where would I write that in, ACAD.lsp, ACAD2000doc.lsp, or the startup.lsp. I also need it to save after running the fliter delete lisp.


<edit: added to title>
« Last Edit: November 09, 2006, 11:24:01 AM by CAB »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: I need some advice..please?
« Reply #1 on: November 09, 2006, 10:41:39 AM »
In the acaddoc.lsp add a line something like this:

Code: [Select]
(load "lfd") lfd
assuming of course that "lfd" is the command name.

To make it save, simply add the save command to the lfd lisp

Code: [Select]
(if (= (getvar "DWGTITLED") 1)(vl-cmdf "save"))
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TomREd

  • Guest
Re: I need some advice..please?
« Reply #2 on: November 09, 2006, 11:11:33 AM »
DUDE YOUR MY HERO.THANKS A BUNCH!

TomREd

  • Guest
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #3 on: November 09, 2006, 11:29:49 AM »
i need to write in a purge after the lfd runs and before the save. also i added the load lfd line into my acad2000doc.lsp, yet i cant see it running the command when I open a drawing, is there a cetain spot in the routine i ned to add this line or not (load "lfd") lfd

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #4 on: November 09, 2006, 11:55:17 AM »
It should be added at the end of the file, actually if you want the honest truth, you should not be making changes to the acad2000doc.lsp, but rather put it in acaddoc.lsp (if there is not one, you can create it and put it in the support path)

It is likely the command line suppression in the acad2000doc.lsp will limit the things you can see on the command line during load anyway.

If you want to purge the drawing, you should add another line to the lfd lisp to do just that. A simple purge macro should do the trick:

Code: [Select]
(vl-cmdf "purge" "a" "*" "n")

Make sure you put the save command after the purge or your changes will not be saved in the initial save after opening. In fact you may want to change the save line to "qsave" because I think there are a couple of instances where save would prompt the user resulting in AutoCAD pausing for user input.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #5 on: November 09, 2006, 12:11:03 PM »
Code: [Select]
(vla-PurgeAll(vla-get-ActiveDocument(vlax-get-acad-object)))

TomREd

  • Guest
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #6 on: November 09, 2006, 12:12:48 PM »
I had already made the change from save to qsave, and I created the Acaddoc.lsp file and remove the added code from the acad2000doc.lsp, and put into the then newly created file, yet when I reload the new lisp i created and open a drawing, the lfd command that im trying to get to run automaticly isn't starting. Is it even possible to get a specific lisp routine to run without the user doing so.

TomREd

  • Guest
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #7 on: November 09, 2006, 12:15:24 PM »
also i decide against the adding in of the purge, cause i dont want to have to reload all my layers everytime I open a new drawing.

Just so you guys know your too kind for helping me figure this out, I need to learn lisp, but its all greek to me until I can see the code and see it work, to understand what im doing. basicly thanks for your guys help!!!

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #8 on: November 09, 2006, 12:18:34 PM »
indeed .. it should be loading and running everytime you open a drawing. Try this ..
In the lfd lisp file, simply add the name of the lisp to the end of the lisp file.

For example:
Code: [Select]
(defun c:lfd()
(do my stuff here)
)
(c:lfd)
Now whenever lfd is loaded it will execute .. simply the act of loading the lisp will cause it to run.

Evgeniy .. that is a cood piece of code, but it may not fire if vl-load-com is not invoked.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TomREd

  • Guest
Re: I need some advice..please? AutoLoad & Run a lisp?
« Reply #9 on: November 09, 2006, 12:30:41 PM »
SO AWESOME :-D :-D :-D

I'm jumping around my office dancing like a retard......whooooooo

You have made my day fellas!!!!