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

Too many arguments

3 REPLIES 3
Reply
Message 1 of 4
sovby
421 Views, 3 Replies

Too many arguments

I'm getting closer on this but now it says that i have too many arguments. I copied this code in from another routine that i found online. Can anyone dicipher this?

 

This is the message i get when i check the text:

 

; error: too many arguments: (IF (OR ( ... ) ( ... ) ( ... ) ... ) (SETQ FOLDR&FLNAME_2COPY ( ... )) (IF ( ... ) ( ... )) ... )

 

Here is my code:

 

(IF
(or
(member
(strcase (GETVAR "PROJECTNAME"))
'("CDG")
); member
(= (strcase (GETVAR "ORIENTATION")) "HORIZONTAL")
(= (strcase (GETVAR "LOCATION")) "BOTTOM")
(= (strcase (GETVAR "SHTSIZE")) "8.5X11")
); or
(setq foldr&flname_2copy
'("H:\\Overlays\\CDG\\" ;<<< input here folder path of source
"skhb.dwg" ;<<< input here filename to be copied
)
) ;_ end_setq
(if (findfile (apply 'strcat foldr&flname_2copy))
(if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy)))
(alert "\n File Exists in Destination Folder")
(progn
(setq curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy)))
(vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir)
(prompt (strcat (strcase (cadr foldr&flname_2copy))
" copied to "
(strcase (getvar "dwgprefix"))
) ;_ end_strcat
) ;_ end_prompt
) ;_ end_progn
) ;_ end_if

); if 
(alert "\n Source File Does not Exist")
) ;_ end_if projectname
(princ)

3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: sovby

Something like this perhaps

(IF
  (or
    (member
      (strcase (GETVAR "PROJECTNAME"))
      '("CDG")
    )					; member
    (= (strcase (GETVAR "ORIENTATION")) "HORIZONTAL")
    (= (strcase (GETVAR "LOCATION")) "BOTTOM")
    (= (strcase (GETVAR "SHTSIZE")) "8.5X11")
  )					; or
  (progn;; <<<<
   (setq foldr&flname_2copy
	  '("H:\\Overlays\\CDG\\";<<< input here folder path of source
	    "skhb.dwg";<<< input here filename to be copied
	   )
   ) ;_ end_setq
   (if (findfile (apply 'strcat foldr&flname_2copy))
     (if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy)))
       (alert "\n File Exists in Destination Folder")
       (progn
	 (setq
	   curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))
	 )
	 (vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir)
	 (prompt (strcat (strcase (cadr foldr&flname_2copy))
			 " copied to "
			 (strcase (getvar "dwgprefix"))
		 ) ;_ end_strcat
	 ) ;_ end_prompt
       ) ;_ end_progn
     ) ;_ end_if
     (alert "\n Source File Does not Exist")
   ); if
   );; progn <<<<
) ;_ end_if projectname

 

HTH

Henrique

EESignature

Message 3 of 4
Kent1Cooper
in reply to: sovby


@sovby wrote:

I'm getting closer on this but now it says that i have too many arguments. I copied this code in from another routine that i found online. Can anyone dicipher this?

 

This is the message i get when i check the text:

 

; error: too many arguments: (IF (OR ( ... ) ( ... ) ( ... ) ... ) (SETQ FOLDR&FLNAME_2COPY ( ... )) (IF ( ... ) ( ... )) ... )

...


Again, if I'm reading it right, I think this is the adjustment you need to make.  An (if) expression can accept a maximum of three arguments: a 'test' expression, a 'then' expression [if the test returns anything other than nil], and [optionally] an 'else' expression [if the test returns nil]. As you have it:

 

(IF ; [outermost]
  (or ; the 'test' expression
    (member
      (strcase (GETVAR "PROJECTNAME"))
      '("CDG")
    ); member
    (= (strcase (GETVAR "ORIENTATION")) "HORIZONTAL")
    (= (strcase (GETVAR "LOCATION")) "BOTTOM")
    (= (strcase (GETVAR "SHTSIZE")) "8.5X11")
  ); end or and 'test' for outermost (if)
  (setq foldr&flname_2copy ; the 'then' expression for the outermost (if)
    '("H:\\Overlays\\CDG\\" ;<<< input here folder path of source
    "skhb.dwg" ;<<< input here filename to be copied
    ); end quoted list
  ) ;_ end_setq

  (if (findfile (apply 'strcat foldr&flname_2copy)); the 'else' expression for the outermost (if) [when the test returns nil] is the mid-level (if)
    (if (findfile (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy))); the 'then' expression for the mid-level (if) is the innermost (if)
      (alert "\n File Exists in Destination Folder"); the 'then' expression for the innermost (if)
      (progn ; the 'else' expression for the innermost (if)
        (setq curr_dir (strcat (getvar "dwgprefix") (cadr foldr&flname_2copy)))
        (vl-file-copy (apply 'strcat foldr&flname_2copy) curr_dir)
        (prompt

          (strcat (strcase (cadr foldr&flname_2copy))
            " copied to "
            (strcase (getvar "dwgprefix"))
          ) ;_ end_strcat
        ) ;_ end_prompt
      ) ;_ end_progn and 'else' expression for innermost (if)
    ) ;_ end_if [innermost] and 'then' expression for mid-level (if)
  ); end if [mid-level] and 'else' expression for outermost (if), which is the last argument it can accept, therefore:
  (alert "\n Source File Does not Exist"); this becomes one more argument than the outermost (if) can accept,

    ; but given what it says, I think it should be the 'else' expression for the mid-level (if)
) ;_ end_if projectname [outermost]
(princ)

 

So I think the end should be re-arranged:

....

      ) ;_ end_progn and 'else' expression for innermost (if)
    ) ;_ end_if [innermost] and 'then' expression for mid-level (if)
    (alert "\n Source File Does not Exist"); 'else' expression for the mid-level (if) [moved up one line]
  ); end if [mid-level] and 'else' expression for outermost (if) now after the (alert)

) ;_ end_if projectname [outermost]
(princ)

Kent Cooper, AIA
Message 4 of 4
sovby
in reply to: Kent1Cooper

Thanks Kent,

That works now. At least it works in the text editor. I will have to wait till i get to the office to test it in the real world. I'm sure theres some more tweaking to do but im getting closer & closer thanks to everyone who has giving me help. I would never have gotten this far if it wasnt for you guys. Do you think i will have to do the next part as a new routine? what i want to do is to attach the titleblock as an xref once the correct one is copied to the current directory. I want sure if it was possible to do this as one routine or not or would it be too complicated?

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

Post to forums  

Autodesk Design & Make Report

”Boost