Too many arguments when running lisp routine

Too many arguments when running lisp routine

Jason.Rugg
Collaborator Collaborator
2,743 Views
12 Replies
Message 1 of 13

Too many arguments when running lisp routine

Jason.Rugg
Collaborator
Collaborator

I have the following lisp routine that was working perfectly, then after relaunching acad and running the command the command line returns: “Too Many Arguments”

 

As far as I can tell nothing has changed but I have not the slightest clue as to why it’s not working now. 

 

Any suggestions?

 

(defun c:MENUFIX (/ f)

  (setq f (findfile "R:\\CAD\\Keys\\Menu\\2019\\KCI-Client Print.cuix"))

    (progn (setvar 'filedia 0)

   (command "_.menuunload" "KCI-Client_Print")

   (command "_.menuload" f)

   (setvar 'filedia 1)

   )        

  (princ)

)

Accepted solutions (1)
2,744 Views
12 Replies
Replies (12)
Message 2 of 13

dbhunia
Advisor
Advisor

Try this ....... (check the path)

 

(defun c:MENUFIX (/ f)
  (setq f (findfile "R:\\CAD\\Keys\\Menu\\2019\\KCI-Client Print.cuix"))
  (setvar 'filedia 0)
  (if (menugroup "KCI-Client_Print") (command "_.menuunload" "KCI-Client_Print"))
  (command "_.menuload" f)
  (setvar 'filedia 1)
  (princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 13

ВeekeeCZ
Consultant
Consultant

Not really sure... I can see that once there is an underscore in the name, secondly is not. I would prefer if there was not at both.

btw most of the dialogs are suppressed in lisp automatically.

 

(defun c:MENUFIX (/ f)

  (if (or (setq f (findfile "R:\\CAD\\Keys\\Menu\\2019\\KCI-Client Print.cuix"))
          (prompt (strcat "\nFile not found: 'R:\\CAD\\Keys\\Menu\\2019\\KCI-Client Print.cuix'"))
          )
    (progn
      (command "_.menuunload" "KCI-Client_Print")
      (command "_.menuload" f)))
  (princ)
  )
0 Likes
Message 4 of 13

Jason.Rugg
Collaborator
Collaborator

@ВeekeeCZ The actual file name as seen through Windows Explorer is: KCI-Client Print.cuix (no underscore).

 

If using the command line version of "MENUUNLOAD" and going through the commands it will not accept the file name as is. When typing the file name, after typing "Client" there is a space before Print that ACAD recognizes as an "Enter". If using the dialog version of the command, the dialog box shows the file name with an "_" between Client_Print. Going back to the command line version it will then accept KCI-Client_Print without the file extension .cuix.

 

So hopefully that makes sense and that's the reason for the file name changes.

0 Likes
Message 5 of 13

Jason.Rugg
Collaborator
Collaborator

@dbhunia I get the same "Too many arguments" with your version as well.

0 Likes
Message 6 of 13

ВeekeeCZ
Consultant
Consultant

Hmm, I would prefer to avoid the issue by not using a space in the file name, but you probably can't.

Anyway, I tried that and it works to me with no issues.

 

(defun c:MENUFIX (/ f)

  (if (or (setq f (findfile "c:\\Users\\user\\Desktop\\_Download\\test cui.cuix"))
          (prompt (strcat "\nFile not found: 'c:\\Users\\user\\Desktop\\_Download\\test cui.cuix'"))
          )
    (progn
      (command "_.menuunload" "test_cui")
      (command "_.menuload" f)))
  (princ)
  )

See the command line. Twice the same.

 

Command: MENUFIX
_.menuunload
Enter the name of a Customization Group to unload:test_cui
Customization file unloaded successfully. Customization Group: test_cui

Command: _.menuload
Enter name of customization file to load: C:\Users\user\Desktop\_Download\test cui.cuix
Customization file loaded successfully. Customization Group: TEST_CUI

Command:
Command: MENUFIX
_.menuunload
Enter the name of a Customization Group to unload:test_cui
Customization file unloaded successfully. Customization Group: test_cui

Command: _.menuload
Enter name of customization file to load: C:\Users\user\Desktop\_Download\test cui.cuix
Customization file loaded successfully. Customization Group: TEST_CUI
0 Likes
Message 7 of 13

Jason.Rugg
Collaborator
Collaborator
Accepted solution

Well it's fixed, it's amazing what a system reboot can fix sometimes, not sure what was wrong but it works again after a reboot.

0 Likes
Message 8 of 13

ВeekeeCZ
Consultant
Consultant

Pointless.

0 Likes
Message 9 of 13

Jason.Rugg
Collaborator
Collaborator

@ВeekeeCZ go back and look at my first post to see the code, I did a system reboot and its back to working now, system memory must have needed cleared or something. When using the command line version of MENUUNLOAD, not MENULOAD, you don't have to worry about the file path because it's already loaded.

0 Likes
Message 10 of 13

Jason.Rugg
Collaborator
Collaborator

What's pointless?


 

0 Likes
Message 11 of 13

ronjonp
Mentor
Mentor

@Jason.Rugg wrote:

What's pointless?


 


I didn't even know this thread existed .. I came up with a better solution for you in your original thread about this but don't get a reply? This was not completely pointless, but frustrating nonetheless...

0 Likes
Message 12 of 13

john.uhden
Mentor
Mentor

May I suggest that you not run that routine with your wife.

John F. Uhden

0 Likes
Message 13 of 13

simge_kahramanV7ZQL
Community Visitor
Community Visitor

Hello,

I have a similar problem. I was using a lisp before and now it is not working. It gives "too many argument error". It was working 3 weeks ago but now, not working. I can't understand why?  Is there anyone to help me?

Thank you.

;; ***************************************************
;;     create_dcl  function to create a dcl support   
;;                 file if it does not exist          
;;     Usage : (create_dcl "file name")               
;;     Returns : T if successful else nil             
;; ***************************************************
(defun katgecis ()
(setq key1 (vl-filename-mktemp "0000.dcl")
fn (open key1 "w"))
      (foreach x '(
                   "viewmove : dialog {"
                   "label = \"[E.YILDIZ] -- Mimari Gecis\" ;"
                   ""
                   ": edit_box {"
                   "label = \"DIKEYDE ARCH MESAFE\" ;"
                   "key = \"V_Dist\" ;"
                   "edit_width = 6 ;"
                   "}"
                   ": edit_box {"
                   "label = \"YATAYDA ARCH MESAFE\" ;"
                   "key = \"H_Dist\" ;"
                   "edit_width = 6 ;"
                   "}"
                   ""
                   ""
                   "    ok_cancel;"
   "}"
                  ) ; endlist
        (princ x fn)
        (write-line "" fn)
      ) ; end foreach
      (close fn)
(princ)) 
 
 
;;LISP CODE
 
 
(defun dcl-load ( / )
 
 
(setq userclick T)
(setq dcl_id (load_dialog key1))
 
(if (not (new_dialog "viewmove" dcl_id))(exit))
 
(set_tile "H_Dist" "1.00")
(set_tile "V_Dist" "1.00")
 
(action_tile "cancel" "(done_dialog) (setq userclick nil)")
 
(action_tile "accept"
"(progn
(setq H-Dist (atof (get_tile \"H_Dist\")))
(setq V-Dist (atof (get_tile \"V_Dist\")))
(done_dialog) (setq userclick T)
)";;;progn
);action_tile
 
(start_dialog)
(unload_dialog dcl_id)
(princ)
 
);;defun
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:5 ( / )
(katgecis)
(dcl-load)
);;;defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Down Movement
(defun c:8 ( / )
(if (= V-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(command "-pan" pt1 (polar pt1 (* 1.5 pi) V-Dist))
);;;defun c:2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Up Movement
(defun c:2 ( / )
(setq pt1 (list 0 0 0))
(command "-pan" pt1 (polar pt1 (* 0.5 pi) V-Dist))
);;;defun c:8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Left Movement
(defun c:6 ( / )
(if (= H-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(command "-pan" pt1 (polar pt1 pi H-Dist))
);;;defun c:6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Right Movement
(defun c:4 ( / )
(if (= H-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(command "-pan" pt1 (polar pt1 0 H-Dist))
);;;defun c:4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;YUKARI KOPYALA
(defun c:qqq ( / )
(if (= V-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(setq cob (ssget))
(command "copy" cob "" pt1 (polar pt1 (* 0.5 pi) V-Dist))
);;;defun 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;ASAGI KOPYALA
(defun c:qqw ( / )
(if (= V-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(setq cob (ssget))
(command "copy" cob "" pt1 (polar pt1 (* 1.5 pi) V-Dist))
);;;defun 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;SOLA KOPYALA
(defun c:C4 ( / )
(if (= H-Dist nil) (dcl-load))
(setq cob (ssget))
(setq pt1 (list 0 0 0))
(command "COPY" cob "" pt1 (polar pt1 pi H-Dist))
);;;defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;SAGA KOPYALA
(defun c:C6 ( / )
(if (= H-Dist nil) (dcl-load))
(setq cob (ssget))
(setq pt1 (list 0 0 0))
(command "COPY" cob ""  pt1 (polar pt1 0 H-Dist))
);;;defun 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;YUKARI TASI
(defun c:M8 ( / )
(if (= V-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(setq cob (ssget))
(command "move" cob "" pt1 (polar pt1 (* 0.5 pi) V-Dist))
);;;defun 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;ASAGI TASI
(defun c:M2 ( / )
(if (= V-Dist nil) (dcl-load))
(setq pt1 (list 0 0 0))
(setq cob (ssget))
(command "move" cob "" pt1 (polar pt1 (* 1.5 pi) V-Dist))
);;;defun 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;SOLA TASI
(defun c:M4 ( / )
(if (= H-Dist nil) (dcl-load))
(setq cob (ssget))
(setq pt1 (list 0 0 0))
(command "move" cob "" pt1 (polar pt1 pi H-Dist))
);;;defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;SAGA TASI
(defun c:M6 ( / )
(if (= H-Dist nil) (dcl-load))
(setq cob (ssget))
(setq pt1 (list 0 0 0))
(command "move" cob ""  pt1 (polar pt1 0 H-Dist))
);;;defun 

 

0 Likes