First time lisper failing with "too many arguments"

First time lisper failing with "too many arguments"

Anonymous
Not applicable
866 Views
4 Replies
Message 1 of 5

First time lisper failing with "too many arguments"

Anonymous
Not applicable

Good day!

 

I'm having an issue trying to modify a lisp routine that works for a single object to make it run for a selection of objects. It's very simple. I'm trying to copy multiple dimension values to a clipboard with a "; " string in between each of the dimensions. 

 

The original script that works for copying a single dimension value to a clipboard:

 

(Defun c:Dim2Clip  (/ ss st 2ClipB)
  (vl-load-com)
 (print "Select Dimension...")
         (if (setq ss (ssget "_+.:S" '((0 . "*DIMENSION"))))
           (progn (setq st (vla-get-measurement (setq vl (vlax-ename->vla-object (ssname ss 0)))))
                  (vlax-invoke
                                 (vlax-get (vlax-get (setq 2ClipB (vlax-create-object "htmlfile")) 'ParentWindow)
                                           'ClipBoardData)
                                 'SetData
                                 "Text"
                                 (rtos st))
                  (vlax-release-object 2ClipB)))
    )

 

 

This is my modification that doesn't work with a "too many arguments" error.

 

(Defun c:ddupa  (/ pat ss i st 2ClipB)
  (vl-load-com)
  (setq pat "")
 (print "Select Dimension...")
         (if (setq ss (ssget "_+.:E:S" '((0 . "*DIMENSION"))))
		 (repeat (setq i (sslength ss))
           (progn (setq st (vla-get-measurement (setq vl (vlax-ename->vla-object (ssname ss 0))))))
		   (setq pat (strcat pat (strcat (rtos st) "; ")))
		   (list (ssname ss (setq i (1- i))) '(0 0 0))	   
		   );repeat		   
                  (vlax-invoke
                                 (vlax-get (vlax-get (setq 2ClipB (vlax-create-object "htmlfile")) 'ParentWindow)
                                           'ClipBoardData)
                                 'SetData
                                 "Text"
                                 pat)
                  (vlax-release-object 2ClipB))
    )

 

I would be very grateful for any assistance with this. I'm in a rush with some work that would be singificantly more efficient with this working. 

0 Likes
Accepted solutions (1)
867 Views
4 Replies
Replies (4)
Message 2 of 5

pbejse
Mentor
Mentor
Accepted solution
(Defun c:ddupa (/ pat ss i st 2ClipB)
  (vl-load-com)
  (setq pat "")
  (print "Select Dimension...")
  (if (setq ss (ssget '((0 . "*DIMENSION"))))
    (progn
      (repeat (setq i (sslength ss))
	(setq st (vla-get-measurement
		   (setq vl
			  (vlax-ename->vla-object (ssname ss (setq i (1- i))))
		   )
		 )
	)
	(setq pat (strcat pat (strcat (rtos st) "; ")))

      )					;repeat		   
      (vlax-invoke
	(vlax-get (vlax-get (setq 2ClipB (vlax-create-object "htmlfile"))
			    'ParentWindow
		  )
		  'ClipBoardData
	)
	'SetData
	"Text"
	pat
      )
      (vlax-release-object 2ClipB)
    )
  )
)
Message 3 of 5

pbejse
Mentor
Mentor

on your code

(if
(setq ss (ssget  '((0 . "*DIMENSION")))) <-- none single object selection mode
	(progn  <--- move one line up
	  (repeat (sslength ss)
	    (setq st (vla-get-measurement
		       (setq vl (vlax-ename->vla-object (ssname ss 0)))
		     )
	    )
	    (setq pat (strcat pat (strcat (rtos st) "; ")))
	    (ssdel (ssname ss 0)) <-- no need for counter
	  )
	  (vlax-invoke
	    (vlax-get (vlax-get	(setq 2ClipB (vlax-create-object "htmlfile"))
				'ParentWindow
		      )
		      'ClipBoardData
	    )
	    'SetData
	    "Text"
	    pat
	  )
	)
)

 

 

Message 4 of 5

Anonymous
Not applicable

Thank you so much!!

0 Likes
Message 5 of 5

dlanorh
Advisor
Advisor

I would also remove the (setq vl) bit, as vl is global, never used and might be ambiguous

I am not one of the robots you're looking for