Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

requiring command entry to run lisp

3 REPLIES 3
Reply
Message 1 of 4
telcomCad
206 Views, 3 Replies

requiring command entry to run lisp

Is there a way to get it so the user had to type in a command, i.e. centerline, to run this routine, instead of it running automatically? (I'd like to add this to my acaddoc.lsp, but don't want the routine to run automatically everytime I open a drawing, as there may be instances I don't want this layer created.

Here's the code:

(command "Layer" "New" "Centerlines"
"Color" 252 "Centerlines"
"Lt" "Center" "Centerlines"
"P" "Plot" "Centerlines" ""
)


Sorry for asking so many questions, just thought I'd check with the experts before I delved into multiple books trying to get the answer, everyone's help is GREATLY appreciated.
3 REPLIES 3
Message 2 of 4
M_Hensley
in reply to: telcomCad

Need to add a defun statement:
(defun C:centerline ()
(command "Layer" "New" "Centerlines"
"Color" 252 "Centerlines"
"Lt" "Center" "Centerlines"
"P" "Plot" "Centerlines" "")
)
Message 3 of 4
telcomCad
in reply to: telcomCad

You should see me slapping my forehead now....uh, how could I not think of that? Thanks for the help!
Message 4 of 4
Anonymous
in reply to: telcomCad

And then you can either put that (defun) into the appropriate acadwhatever.lsp file or the
appropriate .mnl file, or you can keep it as its own separate .lsp file and have it loaded by one of
those other files with a line like

(load "centerline")

assuming that you named it centerline.lsp. I'm sure people have various opinions about which way is
better, depending on how you like to manage whatever defined functions you have.

[Personally, I would be inclined to name it something *including the idea of Layer* somehow, such as
'CL-layer' or whatever, because it's for making a Layer. I would expect a command actually *named*
'centerline' to be used to *draw* a center-line, perhaps including automatically making the
Centerlines Layer current, maybe creating it if it doesn't already exist, and possibly saving the
current Layer when it's invoked and setting it back when it's done, etc.]

--
Kent Cooper


wrote...
Need to add a defun statement:
(defun C:centerline ()
(command "Layer" "New" "Centerlines"
"Color" 252 "Centerlines"
"Lt" "Center" "Centerlines"
"P" "Plot" "Centerlines" "")
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost