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

lisp routine help ??!!??

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
197 Views, 14 Replies

lisp routine help ??!!??

now i have 1 simple error that is stopping me from finishing my lisp routine, it goes like this

( setq pa2 (command "_circle" "0,0" "6"))



;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(setq opt
(strcase (getstring "\nkeep going? (Y,N): ")
);strcase
);setq
(cond
((= opt "Y") (pa2))
((= opt "N") (princ "\you have chosen to stop!")(princ))

(T (princ "\nyou have chosen to stop!")(princ))
);cond


thats basically the part of my routine thats causing the prob

if you choose
Y

it returns error no function definition pa2

????? should i be putting in c:pa2 instead or command "pa2" im not sure anyway any help will be awesome as i can finally finish my prog.

i did actually have the getstring as one of them iniget and conditonal type but that didnt work so i tried it this way and it seems to be better but still not fixing the main prob.....

peace out
14 REPLIES 14
Message 2 of 15
Anonymous
in reply to: Anonymous

ok i copied the setq pa2 n pasted it but renamed it pa3 n put pa3 into the opt =y part and it worked but only once, so what i am seeing is that once the setq thing has been used it cannot be used again?? is there a way to allow repeated use of this command pa2??
Message 3 of 15
Anonymous
in reply to: Anonymous

You'll need a While loop surrounding the entire routine to repeat the circle
again or not.

(setq opt "Y")
(While (= opt "Y")
your code goes here....
) ; while ending

Paul

wrote in message news:5682839@discussion.autodesk.com...
ok i copied the setq pa2 n pasted it but renamed it pa3 n put pa3 into the
opt =y part and it worked but only once, so what i am seeing is that once
the setq thing has been used it cannot be used again?? is there a way to
allow repeated use of this command pa2??
Message 4 of 15
Anonymous
in reply to: Anonymous

cheers mate ill giv it a try
Message 5 of 15
Anonymous
in reply to: Anonymous

now it just does it one more time then stops...... i tried putting it aorund the whole set q part and it didnt work either
Message 6 of 15
Anonymous
in reply to: Anonymous

i probably shoul of said this before i want it to keep asking y or n until n is chosen....
Message 7 of 15
Anonymous
in reply to: Anonymous

ok forget everything i tried something different

(initget "Y N")

(setq opt (getkword "\n keep going? [y/n]: "))
(cond (= opt nil))

((= opt "y")
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "" ))


((= opt "N")
(princ "you chose to stop")(princ))


this one works but once you have chosen y it will do it then stop i want it to keep repeating until N is answered???

anyone know
Message 8 of 15
Anonymous
in reply to: Anonymous

Hi j05h,
try this
[code]
(defun c:test (/ opt)
(initget "Y N")
(setq opt (getkword "\nKeep going? [y/n]: "))
(cond ((= opt nil)(command "_solidedit" "f" "extrude" pause "" "P" pause
"" "" ))
((= opt "Y")(command "_solidedit" "f" "extrude" pause "" "P" pause ""
" ))
((= opt "N")(princ "you chose to stop")(exit))
)
(princ)
) ; defun
[/code]

wrote in message news:5682884@discussion.autodesk.com...
ok forget everything i tried something different

(initget "Y N")

(setq opt (getkword "\n keep going? [y/n]: "))
(cond (= opt nil))

((= opt "y")
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "" ))


((= opt "N")
(princ "you chose to stop")(princ))


this one works but once you have chosen y it will do it then stop i want it
to keep repeating until N is answered???

anyone know
Message 9 of 15
Anonymous
in reply to: Anonymous

hey mate yea it just did exactly what i already had done, after it asks y or n, you choose y it will do the command than thats it.... i want it to ask "keep going y n?" again and again until n is chosen....when n is chosen it should exit
Message 10 of 15
Anonymous
in reply to: Anonymous

i just tryed adesus effort but with while in it


(initget "Y N")
(while(setq opt (getkword "\nKeep going? [y/n]: "))
(cond ((= opt nil)(command "_solidedit" "f" "extrude" pause "" "P" pause
"" "" ))
((= opt "Y")(command "_solidedit" "f" "extrude" pause "" "P" pause ""
" ))
((= opt "N")(princ "you chose to stop")(exit)))
)
(princ)

it repeats the command but when you chose y or n it says invalid keyword????
Message 11 of 15
Anonymous
in reply to: Anonymous

maybe like this, i'm not sure
[code]
(defun c:test (/ opt)
(initget "Y N")
(setq opt (getkword "\nKeep going? [y/n]: "))
(cond ((= opt nil)
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "")
(c:test)
)
((= opt "Y")
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "")
(c:test)
)
((= opt "N")(princ "you chose to stop")(exit))
)
(princ)
) ; defun
[/code]

wrote in message news:5682927@discussion.autodesk.com...
hey mate yea it just did exactly what i already had done, after it asks y or
n, you choose y it will do the command than thats it.... i want it to ask
"keep going y n?" again and again until n is chosen....when n is chosen it
should exit
Message 12 of 15
Anonymous
in reply to: Anonymous

ok i think wat you have done there is partly wat i was after but what i typed earlier is only a small part of the routine im writing so it doesnt need the defun, so if u were to put the C: test in it, it would redo the whole routine when i only want that part i showed you.

if i put (while before the (iniget "y n") instead of before (setq opt ....etc it doesnt even ask if you want to keep going it just stops but if i dont include the (iniget "y n") in the (while parenthesis there will be no keywords to chose!! and it will keep saying invalid option keyword!........
Message 13 of 15
Anonymous
in reply to: Anonymous

The function

(setq pa2 (command "_circle" "0,0" "6"))

is going to set the 'pa2' variable to nil, because that is what (command) functions always return.
It is not going to make that (command) function happen when you call for 'pa2' later on. You would
need to (defun) pa2 or some such thing.

--
Kent Cooper


wrote...
now i have 1 simple error that is stopping me from finishing my lisp routine, it goes like this

( setq pa2 (command "_circle" "0,0" "6"))

....
Message 14 of 15
Anonymous
in reply to: Anonymous

Remember I told you to do this before:

(setq opt "Y")
(While (= opt "Y")
your code goes here....
) ; while ending

So you need to set a default value of "Y" to opt first and then you begin
the while loop:

[code]
(defun c:test (/ opt)
; need to set the default value for opt
(setq opt "Y")
; start while loop
(While (= opt "Y")
; your code goes here....
(initget "Y N")
(setq opt (getkword "\nKeep going? [y/n]: "))
(cond
((= opt "Y")
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "")
)
((= opt nil)
(command "_solidedit" "f" "extrude" pause "" "P" pause "" "")
; need to reset the default value again for opt
(setq opt "Y")
)
((= opt "N")
(princ "you chose to stop")
)
) ; cond
(princ)
) ; while ending
) ; defun
[/code]

Paul
wrote in message news:5682936@discussion.autodesk.com...
ok i think wat you have done there is partly wat i was after but what i
typed earlier is only a small part of the routine im writing so it doesnt
need the defun, so if u were to put the C: test in it, it would redo the
whole routine when i only want that part i showed you.

if i put (while before the (iniget "y n") instead of before (setq opt
....etc it doesnt even ask if you want to keep going it just stops but if i
dont include the (iniget "y n") in the (while parenthesis there will be no
keywords to chose!! and it will keep saying invalid option keyword!........
Message 15 of 15
Anonymous
in reply to: Anonymous

ahhh i se now i put this in different to what u said berfore, well it works now thanks for ya help guys

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

Post to forums  

Autodesk Design & Make Report

”Boost