+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    90

    Default Too many arguments issue

    Registered forum members do not see this ad.

    Good morning all!
    I am having trouble figuring out how i should properly fix the following code. I am getting too many arguments in the section highlighted, which makes sense to me but im not entirely sure what to do to fix. do i need to add a progn before the changes? Any help would be appreciated!

    I basically want it to catch all hatch inside blocks that are on that specific layer, and Solid, then change the pattern, scale, and background color of each. I think i have the right process, but I don't think if/and is correct when i have 3 qualifiers. Thanks in advance for any help!

    Code:
    (defun c:planproposedhatch (/ doc)
      (or *colorobject*
          (setq *colorobject*
    	     (vla-getinterfaceobject
    	       (vlax-get-acad-object)
    	       (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2))
    	     )
          )
      )
      (if
        (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-setrgb (list *colorobject* 255 255 255))))
         (progn (vlax-for blk (vla-get-blocks (setq doc (vla-get-Activedocument (vlax-get-acad-object))))
    	      (if (= :vlax-false (vla-get-isxref blk))
    		(vlax-for obj blk
    		  (if (and (= "08_Proposed Data" (strcase (vla-get-layer obj)))
    			   (= "AcDbHatch" (vla-get-objectname obj))
    			   (= "SOLID" (strcase (vla-get-patternname obj)))
    			   (vlax-write-enabled-p obj)
    		      )
    		    (vl-catch-all-apply 'vla-put-patternname obj ANSI31)
    		    (vl-catch-all-apply 'vla-put-ScaleFactor obj 12)
    		    (vl-catch-all-apply 'vla-put-backgroundcolor (list obj *colorobject*))
    		  )
    		)
    	      )
    	    )
    	    (vla-regen doc acallviewports)
         )
      )
      (princ)
    )
    (vl-load-com)
    (princ)

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,271

    Default

    Hi,

    If you would like to implement more actions than once with if function then you need to use progn function.

    Code:
    (progn
                        (vl-catch-all-apply 'vla-put-patternname obj ANSI31)
    		    (vl-catch-all-apply 'vla-put-ScaleFactor obj 12)
    		    (vl-catch-all-apply 'vla-put-backgroundcolor (list obj *colorobject*))
    )

  3. #3
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    955

    Default

    You can also use COND like so:
    Code:
    (cond ((and (= "08_Proposed Data" (strcase (vla-get-layer obj)))
    	    (= "AcDbHatch" (vla-get-objectname obj))
    	    (= "SOLID" (strcase (vla-get-patternname obj)))
    	    (vlax-write-enabled-p obj)
           )
           (vl-catch-all-apply 'vla-put-patternname obj ansi31)
           (vl-catch-all-apply 'vla-put-scalefactor obj 12)
           (vl-catch-all-apply 'vla-put-backgroundcolor (list obj *colorobject*))
          )
    )
    Although your test will always fail here:
    Code:
    (= "08_Proposed Data" (strcase (vla-get-layer obj)))
    Do you see why?

  4. #4
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    90

    Default

    Would that fail because of the strcase?

  5. #5
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    955

    Default

    Quote Originally Posted by K Baden View Post
    Would that fail because of the strcase?
    Bingo!!!!! <- Exclamations added to meet forum 10 character rule on replies...

  6. #6
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,271

    Default

    Quote Originally Posted by K Baden View Post
    Would that fail because of the strcase?
    There is no function definition vla-put-patternname besides the other errors that described above, so try the following:
    Code:
    (if
        (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-setrgb (list *colorobject* 255 255 255))))
         (progn (vlax-for blk (vla-get-blocks (setq doc (vla-get-Activedocument (vlax-get-acad-object))))
    	      (if (= :vlax-false (vla-get-isxref blk))
    		(vlax-for obj blk
    		  (if (and (vlax-write-enabled-p obj)
                               (= "08_PROPOSED DATA" (strcase (vla-get-layer obj)))
    			   (= "AcDbHatch" (vla-get-objectname obj))
    			   (= "SOLID" (strcase (vla-get-patternname obj)))   
    		      )
                        (progn 
                          (vla-setPattern obj acHatchPatternTypePreDefined "ANSI31")
                          (vla-put-ScaleFactor obj 12)
    		      (vla-put-backgroundcolor (list obj *colorobject*))
    		  )
    		)
    	      )
                 )
    	    )
    	    (vla-regen doc acallviewports)
         )
      )
    Last edited by Tharwat; 13th Feb 2018 at 06:27 pm.

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    955

    Default

    You messing with him?
    Code:
    (= "08_PROPOSED DAtA" (strcase (vla-get-layer obj)))

  8. #8
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,271

    Default

    Quote Originally Posted by ronjonp View Post
    You messing with him?
    Code:
    (= "08_PROPOSED DAtA" (strcase (vla-get-layer obj)))
    No. You got my wrong

  9. #9
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    90

    Default

    Thanks everyone! I'll give this a go and see how it works! I appreciate everyone helping out. Before it wasnt really doing anything, and I assume it is because of my incorrect vla-put-patternname. I assumed that would be the function definition simply due to how you "get" it. Thanks!! I will give this a shot!

    Another quick question would be, if I wanted for example all blokcs that names end in "_PLAN" to have the hatch scale set to 12 and all blocks that end in "_ELEV" to set the hatch scale to 60, would that involve a (cond) surrounding the function that is updating the scale already?

  10. #10
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    90

    Default

    Registered forum members do not see this ad.

    Does anyone know how to make this affect dynamic blocks as well? It seems to only be working on regular blocks, and right now it isn't changing the background color.

    After testing and a little searching i also found that vla-put-patternscale is what i wanted rather than vla-put-scalefactor.

    So its doing everything except adding the BG color, and it's only working on regular blocks.

    The majority of blocks this will be changing are dynamic. Any ideas? Any advice would help! Thanks in advance.

    Code:
    (defun c:planproposedhatch (/ doc)
      (or *colorobject*
          (setq *colorobject*
    	     (vla-getinterfaceobject
    	       (vlax-get-acad-object)
    	       (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2))
    	     )
          )
      )
      (if
        (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-setrgb (list *colorobject* 255 255 255))))
         (progn (vlax-for blk (vla-get-blocks (setq doc (vla-get-Activedocument (vlax-get-acad-object))))
    	      (if (= :vlax-false (vla-get-isxref blk))
    		(vlax-for obj blk
    		  (if (and (vlax-write-enabled-p obj)
                               (= "08_Proposed Data" (vla-get-layer obj))
    			   (= "AcDbHatch" (vla-get-objectname obj))
    			   (= "SOLID" (strcase (vla-get-patternname obj)))   
    		      )
                        (progn 
                          (vla-setPattern obj acHatchPatternTypePreDefined "ANSI31")
                          (vla-put-patternscale obj 12)
    		      (vla-put-backgroundcolor (list obj *colorobject*))
    		    )
    		)
    	      )
                 )
    	    )
    	    (vla-regen doc acallviewports)
         )
      )
    (vl-load-com)
    
    (princ)
    );defun

Similar Threads

  1. Too many arguments error
    By LosGirk in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 16th Oct 2014, 09:57 pm
  2. Error: Too few arguments ?
    By Xelathrone in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 3rd Apr 2014, 05:13 am
  3. Error: too few arguments
    By arunr_18 in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 20th Jul 2013, 09:49 pm
  4. Arguments
    By The Buzzard in forum AutoLISP, Visual LISP & DCL
    Replies: 23
    Last Post: 24th Mar 2010, 04:29 pm
  5. Too many Arguments
    By Enigma in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 21st Apr 2009, 07:27 pm

Bookmarks

Posting Permissions

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