Message 1 of 7
Error too many Arguments (AKA I can't figure out what's wrong with my code)

Not applicable
01-19-2017
06:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I work in transmission engineering, and for a small exercise to learn some AutoLISP in my downtime I wrote a code to calculate and plot the sag of a line in AutoCAD. It looks right to me, but AutoCAD says there's are too many arguments in one section (Lines 30 to 36). I've compared that section to similar sections in other LISP programs I've written, and I can't seem to find the error. What am I missing? I've put the section I'm having issues with in bold red.
; goal: make an autocad program that can plot accurate sagging for lines (defun c:autosag () ;---------User Inputs----------- (setq p1 (getpoint "Choose starting pole")) (setq p2 (getpoint "Choose ending pole")) (setq tension (getint "Tension: ")) (setq weight (getint "Weight per unit length: ")) ;--------- Snapping ---------------- (setq oldsnap (getvar "osmode")) (setq oldblipmode (getvar "blipmode")) ;switch off system variables (setvar "osmode" 0) (setvar "blipmode" 0) ;---------Find X&Y values------- (setq x0 (car p1)) (setq y0 (cadr p1)) (setq xf (car p2)) (setq yf (cadr p2)) (setq l (- xf x0)) (setq h (- yf y0)) (setq lsqr (* l l)) (if (eq h 0) (setq sag (/ (* weight lsqr) (* 8 tension))) ;sag at (setq x_sag (/ l 2)) (setq y_sag (- y0 sag)) ) (if (/= h 0) ;Find x1 & x2 (setq x1 (- (/ l 2) (/ (* tension h) (* weight l)))) (setq x2 (+ (/ l 2) (/ (* tension h) (* weight l)))) ;Find sag (setq sag (/ (* weight (* x1 x1)) (* 2 tension))) ;sag at (setq x_sag (+ x0 x1)) (setq y_sag (- y0 sag)) ) ;xy variable (setq sagPoint '(x_sag y_sag)) ;---------Draw the Curve------ (command "spline" p1 sagPoint p2 ) (setvar "osmode" oldsnap) (setvar "blipmode oldblipmode") )