Results 1 to 8 of 8

Thread: Need a little debugging help: "Error, too few arguments"

  1. #1
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Question Need a little debugging help: "Error, too few arguments"

    Hey All,

    I can't seem to find the error of my ways in this code. Can anyone take a peek and tell me what's wrong?

    Thanks

    Code:
    (defun c:BlockReplace (old new / ss)
      (vl-load-com)
      (command "-insert" "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\blocks\\Balloon_Tag.dwg" ^C)
      (setq old ("Balloon_T,Balloon_TL,Balloon_TR,Balloon_L,Balloon_R,Balloon_B,Balloon_BL,Balloon_BR"))
      (if
        (and
          (setq ss (ssget "_X" (list
                               '(0 . "INSERT")
    			   '(8 . "TAGS")
                                (cons 2 old)
                               '(66 . 1)
                               '(410 . "Model")
    			   )
                            )); there are some
          (tblsearch "Balloon_Tag" new); the Block is defined
        ); and
        (foreach ; then
          x
          (mapcar 'cadr (ssnamex ss))
          (vla-put-name (vlax-ename->vla-object x) new)
        ); foreach
      ); if
      (princ)
    ); defun

  2. #2
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Need a little debugging help: "Error, too few arguments"

    Found a couple of issues: didn't have the right syntax of "tblsearch", didn't define the variable "new". Now get "too few arguments", lol.

    Code:
    (defun c:BlockReplace (old new / ss)
      (vl-load-com)
      (command "-insert" "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\blocks\\Balloon_Tag.dwg" ^C)
      (setq old ("Balloon_T,Balloon_TL,Balloon_TR,Balloon_L,Balloon_R,Balloon_B,Balloon_BL,Balloon_BR"))
      (setq new ("Balloon_Tag"))
      (if
        (and
          (setq ss (ssget "_X" (list
                               '(0 . "INSERT")
    			   '(8 . "TAGS")
                                (cons 2 old)
                               '(66 . 1)
                               '(410 . "Model")
    			   )
                            )); there are some
          (tblsearch "block" new); the Block is defined
        ); and
        (foreach ; then
          x
          (mapcar 'cadr (ssnamex ss))
          (vla-put-name (vlax-ename->vla-object x) new)
        ); foreach
      ); if
      (princ)
    ); defun

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

    Default Re: Need a little debugging help: "Error, too few arguments"

    Couple of things to consider....

    When you prefix the Defun call's Symbol with "C:" you're defining a Command, and Commands do not accept parameters (arguments).

    Here's some quickly written alternatives to the code you posted, where to Command uses hard-coded input, and the Sub-Function accepts parameters:

    Code:
    (vl-load-com)
    
    (defun c:FooCommand (/ ss new)
      (command
        "-insert"
        "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\blocks\\Balloon_Tag.dwg"
        ^C
      )
    
      (if (and (setq ss
                      (ssget
                        "_x"
                        '((0 . "INSERT")
                          (8 . "TAGS")
                          (2
                           .
                           "Balloon_T,Balloon_TL,Balloon_TR,Balloon_L,Balloon_R,Balloon_B,Balloon_BL,Balloon_BR"
                          )
                          (66 . 1)
                          (410 . "Model")
                         )
                      )
               )
               (tblsearch "block" (setq new "Balloon_Tag"))
          )
        (progn
          (vlax-for x (setq ss (vla-get-activeselectionset
                                 (vla-get-activedocument
                                   (vlax-get-acad-object)
                                 )
                               )
                      )
            (vla-put-name x new)
          )
          (vla-delete ss)
        )
      )
      (princ)
    )
    
    (defun FooSubFunction (old new / ss)
      (command
        "-insert"
        "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\blocks\\Balloon_Tag.dwg"
        ^C
      )
    
      (if (and (setq ss
                      (ssget
                        "_x"
                        (list '(0 . "INSERT")
                          '(8 . "TAGS")
                          (cons 2 old)
                          '(66 . 1)
                          '(410 . "Model")
                         )
                      )
               )
               (tblsearch "block" new)
          )
        (progn
          (vlax-for x (setq ss (vla-get-activeselectionset
                                 (vla-get-activedocument
                                   (vlax-get-acad-object)
                                 )
                               )
                      )
            (vla-put-name x new)
          )
          (vla-delete ss)
        )
      )
      (princ)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Need a little debugging help: "Error, too few arguments"

    Well, that works well, but I'm not sure I follow you. Aside from defining "old" elsewhere, the only thing I see different is the placement of the "new" behind the slash for the arguments instead of in front of it.. Is that it? I didn't think that had an impact. So local is REAL local...

    Thanks for your help tho'.

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Need a little debugging help: "Error, too few arguments"

    What error(s) are you receiving?

    What Renderman is saying is the way you currently have the routine coded, you would not be able to pass the necessary arguments to the routine. You would have to enclose the routine within a set of parenthesis with the associated arguments included. This would make the c: prefix unnecessary.

    There may be other errors, but that is the first one I have encountered at the moment.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

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

    Default Re: Need a little debugging help: "Error, too few arguments"

    Quote Originally Posted by stusic View Post
    Well, that works well, but I'm not sure I follow you. Aside from defining "old" elsewhere, the only thing I see different is the placement of the "new" behind the slash for the arguments instead of in front of it.. Is that it? I didn't think that had an impact. So local is REAL local...
    Just to make sure that the basics are covered first, perhaps you'd do well to go back over the documentation for Defun.

    Separately, Lee has some great tutorials on his site... Consider this one as it relates to this topic: Localizing Variables
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: Need a little debugging help: "Error, too few arguments"

    Quote Originally Posted by RenderMan View Post
    Separately, Lee has some great tutorials on his site... Consider this one as it relates to this topic: Localizing Variables
    Thank you for showing me this; that's something I've missed and didn't realize the use or importance.

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

    Default Re: Need a little debugging help: "Error, too few arguments"

    Quote Originally Posted by stusic View Post
    Thank you for showing me this; that's something I've missed and didn't realize the use or importance.
    You're welcome; 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 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  2. Replies: 5
    Last Post: 2009-11-19, 09:03 PM
  3. DEFUN's "arguments"
    By BeKirra in forum AutoLISP
    Replies: 6
    Last Post: 2009-03-18, 09:31 PM
  4. Replies: 4
    Last Post: 2006-11-10, 03:50 PM
  5. Replies: 1
    Last Post: 2005-11-15, 07:35 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
  •