Results 1 to 7 of 7

Thread: Error: too few arguments in a function

  1. #1
    Member
    Join Date
    2013-06
    Posts
    6
    Login to Give a bone
    0

    Question Error: too few arguments in a function

    Hello, I am currently developing a routine that will find the total length of all selected polylines, lines ect, and, if the user would like, estimate how long it will take a machine to cut it. I recently separated the code so that the estimated time was an optional function. But now when I run it Cad, not the build window, tells me I have too few arguments, I've been staring at it all day and surfing the boards for anything that may help but alas I can't figure it out, is there anyone who could point me in the right direction?
    Much Thanks!

    Code:
     
    (defun C:justdoit (ssSelections sngLength runType a)
    
    (setq ssSelections (ssget (list (cons 0 "*POLYLINE,LINE,ARC,CIRCLE,SPILNE")))
         	   sngLength	0
          )
      (initget "Yes No")
      (setq runType (getkword "\n Would you like the Estimated Machining Time to be Calculated? Yes/<No>: "))
      (if (= runType No)    
    	(setq a (function <funtype1>))
        	(setq a (function <funtype2>))
        )
    	    
    
    
    
    
      
      (defun funtype1 (/ intCount entItem sngLength objItem)
          
          (repeat (setq intCount (sslength ssSelections))
           (setq intCount  (1- intCount)
         		entItem   (ssname ssSelections intCount)
         		objItem   (vlax-ename->vla-object entItem)
         		sngLength (+ snglength (vlax-curve-getDistAtParam objItem 
         				   (vlax-curve-getEndParam objItem)
         				  );vlax
    			     );+sngLength 
           );setq
          );loop
          sngLength
       );function
    
    
    
    
    
    
      
    (defun C:GetLength (/ intCount entItem sngLength objItem impSpeed nubTools
    		    passDepth materialThickness passNub machTime)
    
    
      			(setq 	impSpeed	(getreal "\nWhat is the feedrate (IMP value) of your machine? ")
    				nubTools	(getreal "\nHow many cutting heads will be used?")
    				passDepth	(getreal "\nWhat is the pass depth (inches value)?")
    				materialThickness(getreal "\nWhat is the thickness of the material (inches) ")       				
           				passNub		(/ materialThickness passDepth)       				 
           				machTime	(* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
    	);setq
      
    
    
      	(repeat  (setq intCount (sslength ssSelections)
    		 intCount  (1- intCount)
           		 entItem   (ssname ssSelections intCount)
         		 objItem   (vlax-ename->vla-object entItem)
         		 sngLength (+ snglength (vlax-curve-getDistAtParam objItem 
         				   (vlax-curve-getEndParam objItem)
         				  );vlax1
    			     );+snglength
    		 machTime  (* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
    			);setq
    	  ); Loop
    sngLength
     machTime 
      );function
      );main function

  2. #2
    AUGI Addict
    Join Date
    2006-04
    Location
    (getpoint "Anywhere on the Enter Key =>")
    Posts
    1,160
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    Quote Originally Posted by lepley.amber388103 View Post
    Hello, I am currently developing a routine that will find the total length of all selected polylines, lines ect, and, if the user would like, estimate how long it will take a machine to cut it. I recently separated the code so that the estimated time was an optional function. But now when I run it Cad, not the build window, tells me I have too few arguments, I've been staring at it all day and surfing the boards for anything that may help but alas I can't figure it out, is there anyone who could point me in the right direction?
    Much Thanks!

    Code:
     
    (defun C:justdoit (ssSelections sngLength runType a)
    
    (setq ssSelections (ssget (list (cons 0 "*POLYLINE,LINE,ARC,CIRCLE,SPILNE")))
                sngLength    0
          )
      (initget "Yes No")
      (setq runType (getkword "\n Would you like the Estimated Machining Time to be Calculated? Yes/<No>: "))
      (if (= runType No)    
        (setq a (function <funtype1>))
            (setq a (function <funtype2>))
        )
            
    
    
    
    
      
      (defun funtype1 (/ intCount entItem sngLength objItem)
          
          (repeat (setq intCount (sslength ssSelections))
           (setq intCount  (1- intCount)
                 entItem   (ssname ssSelections intCount)
                 objItem   (vlax-ename->vla-object entItem)
                 sngLength (+ snglength (vlax-curve-getDistAtParam objItem 
                            (vlax-curve-getEndParam objItem)
                           );vlax
                     );+sngLength 
           );setq
          );loop
          sngLength
       );function
    
    
    
    
    
    
      
    (defun C:GetLength (/ intCount entItem sngLength objItem impSpeed nubTools
                passDepth materialThickness passNub machTime)
    
    
                  (setq     impSpeed    (getreal "\nWhat is the feedrate (IMP value) of your machine? ")
                    nubTools    (getreal "\nHow many cutting heads will be used?")
                    passDepth    (getreal "\nWhat is the pass depth (inches value)?")
                    materialThickness(getreal "\nWhat is the thickness of the material (inches) ")                       
                           passNub        (/ materialThickness passDepth)                        
                           machTime    (* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
        );setq
      
    
    
          (repeat  (setq intCount (sslength ssSelections)
             intCount  (1- intCount)
                    entItem   (ssname ssSelections intCount)
                  objItem   (vlax-ename->vla-object entItem)
                  sngLength (+ snglength (vlax-curve-getDistAtParam objItem 
                            (vlax-curve-getEndParam objItem)
                           );vlax1
                     );+snglength
             machTime  (* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
                );setq
          ); Loop
    sngLength
     machTime 
      );function
      );main function
    1st of all, I am also learning autolisp.
    And 2nd, as I can see that you just start to learn the program.
    The suggestion from my experience is that it would be easier if you grab a simple code and learn from it.
    And before loading the code to autocad, you should check it out by using "VLIDE" in autocad (coomand = "VLIDE").
    On the code you posted, there is paren putting in the wrong location, and function "<funtype2>" is missing.
    You may need to pay more attention to the details.
    HTH.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    Quote Originally Posted by lepley.amber388103 View Post
    ... tells me I have too few arguments, I've been staring at it all day and surfing the boards for anything that may help but alas I can't figure it out, is there anyone who could point me in the right direction?
    You're showing all 'arguments' in lieu of 'variables'... Consider this small change:
    Code:
     
    (defun C:justdoit (;|arguments|; / ;|variables|; ssSelections sngLength runType a)
    
    ;;; <snip>
    ... More on the DEFUN function.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  4. #4
    Member
    Join Date
    2013-06
    Posts
    6
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    Thank you for all the help on this, I ironed out the arguments issue and done a bit of tweaking and now it runs everything up until the point in which the length should be returned when vlide tells me: ; error: bad argument type: numberp: nil.
    I'm sure this is a simple fix but my LISP is very rusty.
    any help on this matter would be greatly appreciated
    Thanks
    Code:
    (defun C:polysum (/ runType a yes no)
      
    (defun funtype1 (/ intCount entItem objItem sngLength)
          
    		(repeat (setq 	intCount    (sslength ssSelections))
    		  	(setq	intCount    (1- intCount)
    			      	entItem     (ssname ssSelections intCount)
    			      	objItem     (vlax-ename->vla-object entItem)
                 			sngLength (+ snglength (vlax-curve-getDistAtParam
    							 objItem 
                            		  (vlax-curve-getEndParam objItem)
                           				);vlax
                        			);+sngLength 
           );setq
          );loop
          (princ (strcat "\nTotal Length "sngLength))
       );function
      
      (defun funtype2 (/ intCount entItem sngLength objItem impSpeed nubTools
    		    passDepth materialThickness passNub machTime)
          
    		   (setq 	impSpeed	(getreal "\nWhat is the feedrate (IMP value) of your machine? ")
    				nubTools	(getreal "\nHow many cutting heads will be used?")
    				passDepth	(getreal "\nWhat is the pass depth (inches value)?")
    				materialThickness(getreal "\nWhat is the thickness of the material (inches) ")       				
           				passNub		(/ materialThickness passDepth)       				 
           				machTime	(* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
    	);setq
      
    
      	(repeat  (setq  intCount (sslength ssSelections))
    		 (setq	intCount  (1- intCount)
           		 	entItem   (ssname ssSelections intCount)
         		 	objItem   (vlax-ename->vla-object entItem)
         		 	sngLength (+ snglength (vlax-curve-getDistAtParam objItem 
         				   (vlax-curve-getEndParam objItem)
         				  );vlax1
    			     );+snglength
    			machTime  (* (/ sngLength impSpeed) passNub(+ 1.5 (* 1.5 nubTools))) ;assuming it takes 1-1/2 minute to change a bit
    			);setq
    	  ); Loop
    (princ (strcat "\nTotal Length "sngLength
    	       "\nEstimated Machine Time "machTime))
      );function
    
      (setq ssSelections (ssget (list (cons 0 "*POLYLINE,LINE,ARC,CIRCLE,SPILNE")))
         	  			 sngLength	0)
    
      (initget "Yes No")
      (setq runType (getkword "\n Would you like the Estimated Machining Time to be Calculated? Yes/<No>: "))
      (if (= runType "No")    
    	(setq a (funtype1))
    		  
        	(setq a (funtype2))
    	      )  
      )

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    The STRCAT function concatenates multiple strings, but you're attempting to concatenate strings and numbers (which is the cause of your bad argument error)... You might find the RTOS function useful.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  6. #6
    Member
    Join Date
    2013-06
    Posts
    6
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    well that make sense haha Thanks!

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Error: too few arguments in a function

    No worries; I'm happy to help.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

Similar Threads

  1. error: too many arguments??
    By tedg in forum AutoLISP
    Replies: 3
    Last Post: 2010-08-31, 02:58 AM
  2. error: too many arguments Using IF Function
    By ccruz in forum AutoLISP
    Replies: 1
    Last Post: 2009-08-06, 09:31 PM
  3. Replies: 12
    Last Post: 2006-12-07, 03:22 PM
  4. Help fix a routine - Error: too few arguments
    By cadd4la in forum AutoLISP
    Replies: 3
    Last Post: 2006-01-10, 06:06 PM
  5. ; error: no function definition: ACET-ERROR-INIT
    By gab.83408 in forum AutoCAD Customization
    Replies: 1
    Last Post: 2005-03-01, 12:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •