"Command: ; error: extra right paren on input"

"Command: ; error: extra right paren on input"

pesctx
Participant Participant
1,210 Views
5 Replies
Message 1 of 6

"Command: ; error: extra right paren on input"

pesctx
Participant
Participant

I'm trying to load this lisp file and I receive "Command: ; error: extra right paren on input".

 

I put one or 2 parenthesis at the finish of the file, but I receive the same error.

 

Any help please.

 

;Show flow direction
;Stefan M. - 26.07.2015
(defun c:flow ( / *error* ms ss e l key d n c y p f a p1 p2 p3 ar)
 (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
 (setq ms (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
 (vla-startundomark acDoc)
 
 (defun *error* (msg)
   (and
     msg
     (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*"))
     (princ (strcat "\nError: " msg))
   )
   (vla-endundomark acDoc)
   (princ)
 )
 (if
   (eq (vla-get-lock (vla-get-activelayer acdoc)) :vlax-true)
   (progn
     (princ "\nCurrent Layer is locked.")
     (exit)
     )
   )

 (if
   (setq ss (ssget ":E:S" '((0 . "POLYLINE") (-4 . "&=") (70 . )))
   (progn
     (or (tblsearch "layer" "arrow") (vla-add (vla-get-layers acDoc) "arrow"))
     (setq e (ssname ss 0)
           l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e))
           )
     (initget "Distance Items" 1)
     (setq key (getkword (strcat "\nPolyline length = " (rtos l) "\nChoose a method [Distance/Items]: ")))
     (if
       (eq key "Distance")
       (setq d (getdist "\nDistance between arrows: "))
       (setq n (getint  "\nNumber of arrows: "))
       )
     (if n (setq d (/ l n)))
     (if d
       (progn
         (setq c 0.0 y (/ d 5.0))
         (while (< (setq c (+ c d)) l)
           (setq p (vlax-curve-getpointatdist e c)
                 f (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint e p))
                 a (angle '(0.0 0.0) f)
                 p1 (polar p a (if (minusp (caddr f)) (- y) y))
                 p2 (polar p1 (+ a (* pi 0.5)) (* 0.4 y))
                 p3 (polar p1 (- a (* pi 0.5)) (* 0.4 y))
                 ar (vla-Add3DPoly ms
                      (vlax-safearray-fill
                        (vlax-make-safearray vlax-vbDouble '(0 . )
                        (append p2 p p3)
                        )
                      )
                 )
           (vla-put-closed ar :vlax-true)
;;;            (vla-put-color ar (if (minusp (caddr f)) acred acyellow))
           (vla-put-layer ar "arrow")
           )
         )
       )   
     )
   )
 (*error* nil)
 (princ)
 )

 

The code is from here:  https://www.cadtutor.net/forum/topic/57478-arrow-on-3d-polyline-to-show-water-flow-direction/

0 Likes
Accepted solutions (1)
1,211 Views
5 Replies
Replies (5)
Message 2 of 6

Sea-Haven
Mentor
Mentor

Ok 1st thing download Notepad++ it has in built lisp checking, or use VLIDE.

 

Not saying this is correct but seems right

 

;Show flow direction
;Stefan M. - 26.07.2015
(defun c:flow ( / *error* ms ss e l key d n c y p f a p1 p2 p3 ar)
 (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
 (setq ms (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
 (vla-startundomark acDoc)
 
 (defun *error* (msg)
   (and
     msg
     (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*"))
     (princ (strcat "\nError: " msg))
   )
   (vla-endundomark acDoc)
   (princ)
 )
 (if
   (eq (vla-get-lock (vla-get-activelayer acdoc)) :vlax-true)
   (progn
     (princ "\nCurrent Layer is locked.")
     (exit)
     )
   )

 (if
   (setq ss (ssget ":E:S" '((0 . "POLYLINE") (-4 . "&=") (70 . )))
   (progn
     (or (tblsearch "layer" "arrow") (vla-add (vla-get-layers acDoc) "arrow"))
     (setq e (ssname ss 0)
           l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e))
           )
     (initget "Distance Items" 1)
     (setq key (getkword (strcat "\nPolyline length = " (rtos l) "\nChoose a method [Distance/Items]: ")))
     (if
       (eq key "Distance")
       (setq d (getdist "\nDistance between arrows: "))
       (setq n (getint  "\nNumber of arrows: "))
       )
     (if n (setq d (/ l n)))
     (if d
       (progn
         (setq c 0.0 y (/ d 5.0))
         (while (< (setq c (+ c d)) l)
           (setq p (vlax-curve-getpointatdist e c)
                 f (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint e p))
                 a (angle '(0.0 0.0) f)
                 p1 (polar p a (if (minusp (caddr f)) (- y) y))
                 p2 (polar p1 (+ a (* pi 0.5)) (* 0.4 y))
                 p3 (polar p1 (- a (* pi 0.5)) (* 0.4 y))
                 ar (vla-Add3DPoly ms
                      (vlax-safearray-fill
                        (vlax-make-safearray vlax-vbDouble '(0 . )
                        (append p2 p p3)
                        )
                      )
                 )
           (vla-put-closed ar :vlax-true)
;;;            (vla-put-color ar (if (minusp (caddr f)) acred acyellow))
           (vla-put-layer ar "arrow")
           )
         )
       )   
     )
   )
   )
 (*error* nil)
 (princ)
 )
 )
0 Likes
Message 3 of 6

pesctx
Participant
Participant

I tried to load it on Autocad 2015 and 2018 using the command appload.

 

I receive the same error: "Command: ; error: extra right paren on input"

 

Vlide tells it's ok.

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

There are some pieces in the code left unfinished.

 

;Show flow direction
;Stefan M. - 26.07.2015
(defun c:flow ( / *error* ms ss e l key d n c y p f a p1 p2 p3 ar)
  
  (or acDoc
      (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq ms (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)))
  (vla-startundomark acDoc)
  
  (defun *error* (msg)
    (and msg
	 (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*EXIT*"))
	 (princ (strcat "\nError: " msg))
	 )
    (vla-endundomark acDoc)
    (princ)
    )
  (if (eq (vla-get-lock (vla-get-activelayer acdoc)) :vlax-true)
    (progn
      (princ "\nCurrent Layer is locked.")
      (exit)
      )
    )
  
  (if (setq ss (ssget ":E:S" '((0 . "POLYLINE"))))
    (progn
      (or (tblsearch "layer" "arrow")
	  (vla-add (vla-get-layers acDoc) "arrow"))
      (setq e (ssname ss 0)
	    l (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e)))
      (initget "Distance Items" 1)
      (setq key (getkword (strcat "\nPolyline length = " (rtos l)
				  "\nChoose a method [Distance/Items]: ")))
      (if (eq key "Distance")
	(setq d (getdist "\nDistance between arrows: "))
	(setq n (getint  "\nNumber of arrows: "))
	)
      (if n
	(setq d (/ l n)))
      (if d
	(progn
	  (setq c 0.0
		y (/ d 5.0))
	  (while (< (setq c (+ c d)) l)
	    (setq p (vlax-curve-getpointatdist e c)
		  f (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint e p))
		  a (angle '(0.0 0.0) f)
		  p1 (polar p a (if (minusp (caddr f)) (- y) y))
		  p2 (polar p1 (+ a (* pi 0.5)) (* 0.4 y))
		  p3 (polar p1 (- a (* pi 0.5)) (* 0.4 y))
		  ar (vla-Add3DPoly ms
		       (vlax-safearray-fill
			 (vlax-make-safearray vlax-vbDouble (cons 0 (1- (length (append p2 p p3)))))
			   (append p2 p p3))))
	    (vla-put-closed ar :vlax-true)
	    ;;;            (vla-put-color ar (if (minusp (caddr f)) acred acyellow))
	    (vla-put-layer ar "arrow"))))))
  (*error* nil)
  (princ)
  )

 

0 Likes
Message 5 of 6

pesctx
Participant
Participant

It's working. Thank you very much.

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Nice one BeekeeCZ, using Notepad ++ makes checking easy as you create looking for these problems.

 

Here is an old one written like 30  years ago gives an idea of where mismatched.

0 Likes