View Full Version : Run a LISP routine from inside another
mpemberton
2006-06-26, 07:44 PM
Hello Everyone.
Is there anyway to run one lisp file inside of another?
here is my example:
(DEFUN C:PStest ()
(COMMAND "LTSCALE" "48")
(COMMAND "DIMSCALE" "96")
(Load plot set up.lsp) (Run plot set up.lsp)
I appreciate any help.
Matt
Some lisp routines do not work inside others, but you can try. You would need to place the name of the routine within parenthesis. This name would include the everything after the defun and before the global / local variable set of parenthesis.
T.Willey
2006-06-26, 07:58 PM
To call a lisp from a lisp, you have to do.
(defun c:MainLisp ()
(c:SecondaryLisp)
or
(SecondaryLisp)
)
It defpends how you named the defun.
Hi Matt,
You can load the "plot set up.lsp" at any time before you need it.
The way you call it is by the defun name (ie, if you create it using (defun c:test ()...) you call it like (c:test), and if you use (defun test (),,) [without the c:] just execute it with (test). Note that the c: in front is just so you can execute that function from the command line (just type "test" to run it) and most of the functions defined for use within another function will not have it.
Also, use setvar instead of command when you are changing system variables such as ltscale and dimscale.
(defun c:PlotSetUp ()
Plot set up code goes here...
);end defun
(defun c:pstest ()
(setvar "ltscale" 48)
(setvar "dimscale" 96)
(c:PlotSetup [arguments, if any])
);end defun
Well shoot. It looks like Tim and Opie beat me to it, but here's my $0.02 anyway.
mpemberton
2006-06-26, 08:25 PM
Thanks everybody for the super quick response time.
I think I mis-lead my question. I have a routine I wrote to screen back colors of floor plans, I am writing a new one to create 20 different plot sheets. After I get past the first initial xrefing the floor plan in; I need to run my screen routine before the active lisp saves 20 drawings.
This is what is going on real short like:
(defun C: Set up Project ()
(stuff)
(stuff)
(stuff)
(Run the screen command)
(stuff)
(stuff)
(stuff)
(save - Close)
..end
Ok, Matt, now I'm confused :?.
You should be able to as previously stated.
Or do you need to run the screen routine once on each of the plot sheets in some kind of loop?
Maybe a step by step of what you are trying to accomplish would help.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.