:error ; too many arguments in

:error ; too many arguments in

Anonymous
Not applicable
1,012 Views
3 Replies
Message 1 of 4

:error ; too many arguments in

Anonymous
Not applicable

Hello all,

 

I'm new to AutoLISP but this is a piece of code I wrote to do some auto dimensioning on polylines

 

I think I'm doing this correctly, but I get ab error called ":error ; too many arguments" in the command line

 

Please let me know if I'm missing something-

 

(defun C:dimensioner (/ pl )
(and (setq pl (ssget '((0 . "LWPOLYLINE"))))
(foreach itm
(setq ptlist (mapcar 'cdr (vl-remove-if-not '(lambda(x)(=(car x) 10))(entget (ssname pl 0)))))
)
)

(setq len (1+ (vl-list-length (cdr ptlist)))) ;retuns the number of co-ordiante pairs in the list called ptlist
(setq p1 (nth 0 ptlist)) ;gets the ith co-ordinate in the list called ptlist
(setq p2 (nth 1 ptlist)) ;gets the jth co-ordinate in the list called ptlist
(setq x1 (nth 0 p1))
(setq x2 (nth 0 p2))
(setq y1 (nth 1 p1))
(setq y2 (nth 1 p2))
(if (= y1 y2)
(
prompt "\nHorizontal dimensioning needed"
(if (< x1 x2)
(
(setq x1 (-2.5+ x1)
x2 (2.5+ x2)
x3 (0.5*(x1+x2))
y1 (5+ y1)
y2 (5+ y2)
y3 (0.5*(y1+y2))
p1 (list (x1 y1))
p2 (list (x2 y2))
p3 (list (x3 y3))); setq ended
(command "dimlinear" p1 p2 p3)
)
(
;do something similar to previous if block
)
(princ))
)
(
prompt "\nVertical dimensioning needed"
)
)
(princ)
)

 

0 Likes
1,013 Views
3 Replies
Replies (3)
Message 2 of 4

pbejse
Mentor
Mentor

@Anonymous wrote:

Hello all,

I'm new to AutoLISP but this is a piece of code I wrote to do some auto dimensioning on polylines

I think I'm doing this correctly, but I get ab error called ":error ; too many arguments" in the command line


 

To find the error, use Debug/Break on error on Vlide

 

As for your code, I dont really understand what your're trying to do here

 

(and (setq pl (ssget '((0 . "LWPOLYLINE"))))
           (foreach
                  itm
                       (setq ptlist
                                  (mapcar 'cdr
                                          (vl-remove-if-not
                                                '(lambda (x)
                                                       (= (car x) 10))
                                                		(entget (ssname pl 0)))))
            )
           )

 

What you have on ssget mode is to allow the user for selection of multiple objects, while you only process one at (ssname pl 0)), better write that as shown below, you can still use the filter and be limited to one selection. 

 

(setq pl (ssget "_:S:E" '((0 . "LWPOLYLINE"))))

 

 

You have wrapped  the ptlist variable inside  foreach function for no reason at all.  unlesss you are planning to process multiple files, I would suggest using repeat or while.

 

The conditions are not clear. is that (= y1 y2) AND (< x1 x2) ?

 

..
(if (= y1 y2)
  (prompt "\nHorizontal dimensioning needed"  <== missing parenthesis 
.. (if (< x1 x2)
...
(prompt "\nVertical dimensioning needed")
             ); if ended here

 

 

That line generate the error message ":error ; too many arguments"  

 

0 Likes
Message 3 of 4

martti.halminen
Collaborator
Collaborator

After you get that missing parenthesis added, here are the next two errors:

 

(if (< x1 x2)
(
(setq x1 (-2.5+ x1) ...

 

IF only accepts a single Lisp expression for the true case. In case you need to group several expressions to one, in Lisp that can't be done by adding just parentheses around those, you need to use the function PROGN, instead.

(if (< x1 x2)
     (progn
         (setq x1 ...

 

The second error: (-2.5+ x1) is not legal Lisp:

_$ (-2.5+ x1)
; error: no function definition: -2
_1$

(That was from the VLIDE console window, if you are not familiar with that)

 

In lisp the mathemathics is done by function calls like everything else, so something like (+ x1 -2.5) might work.

 

_$ (0.5*(x1+x2))
; error: no function definition: X1+X2
_1$

 

That should be (* 0.5 (+ x1 x2))

etc.

 

0 Likes
Message 4 of 4

devitg
Advisor
Advisor

@Anonymous 

 

 

 

0 Likes