PDA

View Full Version : error: too many arguments Using IF Function


ccruz
2009-08-06, 10:54 PM
I"m new to using AutoLISP and have been working on writing a post & footing routine where using User Input draws the post and footing. I've also got a hold of using the IF function and am able to choose what later the post & footing get placed on. So far my routine works just fine.

I'm having problems with it working when I try to add another IF function, so that I have the choice between using two types of footings. (square, rectangle)

I've added the IF function to my routine, and it works all the way until I get to choosing the type of footing. I get the error that I have too many arguments. Is it possible that someone can help me out with what I need to do to get this to work?

1_2 Is the version that works before adding the Type of footing option
1_4 Is the version WITH it that keeps giving me the error

Any help is appreciated!

Opie
2009-08-06, 11:31 PM
Your two if statements in 1_4 are incorrect. You can only have three arguments within an IF function, the test, what to do if the test is true, and what to do if the test is false.

The first one will ask you for the footing size if the FtgType was set to "C". If it is not "C", then it would error out as the FtgSize variable has not been set before trying to draw the circle.

The second if statement could be combined into the first if statement. However, you will need to wrap your code within a progn function.

(if (= (strcase FtgType) "C")
(progn ; If FtgType = "C"
(setq Ftgsize (getreal "Enter Footing Size"))
(command "circle" postref "D" Ftgsize "")
)
(progn ; If FtgType /= "C"
(setq ftgref (list (car postref) (cadr postref)))
(setq flength (getreal "Enter Footing Length"))
(setq fwidth (getreal "Enter Footing Width"))

(setq ftgref1 (/ flength 2))
(setq ftgref2 (/ fwidth 2))

(setq
fpt1 (list (- (car ftgref) ftgref1) (- (cadr ftgref) ftgref2))
)
(setq fpt2 (list (+ (car ftgref) ftgref1) (cadr fpt1)))
(setq fpt3 (list (car fpt2) (+ (cadr ftgref) ftgref2)))
(setq fpt4 (list (car fpt1) (cadr fpt3)))

(command "pline" fpt1 fpt2 fpt3 fpt4 "c")
)
)