; error: too few arguments

Discussion in 'AutoCAD' started by T.Willey, May 19, 2004.

  1. T.Willey

    T.Willey Guest

    I can't find where this error is coming from. I have been looking for it for about an hour. Any help is appreciated.

    (defun c:cl(/ob1 ob2 ob3 ob4)

    (command "undo" "end")
    (command "undo" "group")

    (lt-check)

    (while (setq ob1 (nentsel "\nSelect dimension line to change to center ltype: "))
    (if (= (vl-list-length ob1) 4)
    (progn
    (setq ob2 (entget (caar (cdddr ob1))))
    (if (= (cdr (assoc 0 ob2)) "DIMENSION")
    (progn
    (setq ob3 (entget (car ob1)))
    (if (assoc 6 ob3)
    (setq ob4 (subst (cons 6 "CENTER") (assoc 6 ob3) ob3))
    (setq ob4 (append ob3 (list (cons 6 "CENTER"))))
    )
    (entmod ob4)
    (entupd (cdr (assoc -1 ob2)))
    )
    (prompt "\n No dimension selected: ")
    )
    )
    (prompt "\n No dimension selected: ")
    )
    )

    (command "undo" "end")
    (princ)

    )

    (defun lt-check(/tb1 ltlist1)

    (setq tb1 (tblnext "ltype" T))
    (setq ltlist1 (list (cdr (assoc 2 tb1))))

    (while (setq tb1 (tblnext "ltype"))
    (setq ltlist1 (append ltlist1 (list (cdr (assoc 2 tb1)))))
    )

    (if (not (member "CENTER" ltlist1))
    (command "-linetype" "l" "CENTER" "ACAD.LIN" "")
    )

    )


    Thanks in advance.
     
    T.Willey, May 19, 2004
    #1
  2. Both of your defuns need a space added.

    put a space after the /

    (defun whatever (/ <space here> <then local vars>)

    --

    Autodesk Discussion Group Facilitator


    hour. Any help is appreciated.
     
    Jason Piercey, May 19, 2004
    #2
  3. T.Willey

    ECCAD Guest

    Isn't (command "_linetype"...
    followed by (7) parameters ?

    Bob
     
    ECCAD, May 19, 2004
    #3
  4. T.Willey

    T.Willey Guest

    Command: -LINETYPE

    Current line type: "ByLayer"
    Enter an option [?/Create/Load/Set]: L

    Enter linetype(s) to load: CENTER

    Linetype "CENTER" loaded.

    Enter an option [?/Create/Load/Set]:

    Command: *Cancel*

    I copy pasted that line of code into autocad and it seemed to work. This is what I got when I typed "-linetype" at the command line. But that function seemed to work, so it looks as if something is wrong in the first part.

    Thanks.

    Tim
     
    T.Willey, May 19, 2004
    #4
  5. T.Willey

    T.Willey Guest

    Thanks Jason.
    That did it. Wow so simply and I missed it. Thanks for the fast responses you guys.
    Another problem sloved by this group.

    Tim
     
    T.Willey, May 19, 2004
    #5
  6. T.Willey

    ECCAD Guest

    Oh,
    OK. I missed the <space> on the var.. Duh.

    Bob
     
    ECCAD, May 19, 2004
    #6
  7. T.Willey

    T.Willey Guest

    Now that it works, I was wondering if there is a way to make it work better. How can I make the loop work so that enter is the only way to get out of the command. Right now if I try selecting a dim line, but don't hit it, it exit the command. I could use this in other lisp routines I have, but haven't found a way to make it work like that. Any help is appreciated. Thanks again for all the help.

    Tim
     
    T.Willey, May 20, 2004
    #7
  8. T.Willey

    ECCAD Guest

    Tim,
    Try this technique. (untested).

    ;------------
    (defun c:cl(/ ob1 ob2 ob3 ob4 flag pt)
    (command "undo" "end")
    (command "undo" "group")
    (lt-check)
    ;
    (setq flag 0); exit flag - no point pick
    (while (= flag 0)
    (setq pt nil)
    (setq pt (getpoint "\nSelect dimension line to change to center ltype or {Enter} to quit: "))
    (setq ob1 (nentsel pt)); get object
    ; (setq ob1 (nentsel "\nSelect dimension line to change to center ltype: "))
    (if (= (vl-list-length ob1) 4)
    (progn
    (setq ob2 (entget (caar (cdddr ob1))))
    (if (= (cdr (assoc 0 ob2)) "DIMENSION")
    (progn
    (setq ob3 (entget (car ob1)))
    (if (assoc 6 ob3)
    (setq ob4 (subst (cons 6 "CENTER") (assoc 6 ob3) ob3))
    (setq ob4 (append ob3 (list (cons 6 "CENTER"))))
    ); end if
    (entmod ob4)
    (entupd (cdr (assoc -1 ob2)))
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    (if (= pt nil)(setq flag 1)); no point picked, exit
    ); end while
    ;
    (command "undo" "end")
    (princ)
    ); end function


    (defun lt-check(/ tb1 ltlist1)
    (setq tb1 (tblnext "ltype" T))
    (setq ltlist1 (list (cdr (assoc 2 tb1))))
    (while (setq tb1 (tblnext "ltype"))
    (setq ltlist1 (append ltlist1 (list (cdr (assoc 2 tb1)))))
    )
    (if (not (member "CENTER" ltlist1))
    (command "-linetype" "l" "CENTER" "ACAD.LIN" "")
    )
    )
    ;--------

    Bob
     
    ECCAD, May 20, 2004
    #8
  9. T.Willey

    ECCAD Guest

    Last post will probably fail if ob1 is nil, better check for that.
    add :
    (if ob1
    (progn
    ........
    ); end progn
    ); end if
    ......

    Bob
     
    ECCAD, May 20, 2004
    #9
  10. T.Willey

    T.Willey Guest

    (defun c:cl(/ ob1 ob2 ob3 ob4 flag pt)
    (command "undo" "end")
    (command "undo" "group")
    (lt-check)
    ;
    (setq flag 0); exit flag - no point pick
    (setq os1 (getvar "osmode"))
    (setvar "osmode" 512)
    (while (= flag 0)
    (setq pt nil)
    (setq pt (getpoint "\nSelect dimension line to change to center ltype or {Enter} to quit: "))
    (if pt
    (progn
    (setq ob1 (nentselp pt)); get object
    (if (= (vl-list-length ob1) 4)
    (progn
    (setq ob2 (entget (caar (cdddr ob1))))
    (if (= (cdr (assoc 0 ob2)) "DIMENSION")
    (progn
    (setq ob3 (entget (car ob1)))
    (if (assoc 6 ob3)
    (setq ob4 (subst (cons 6 "CENTER") (assoc 6 ob3) ob3))
    (setq ob4 (append ob3 (list (cons 6 "CENTER"))))
    ); end if
    (entmod ob4)
    (entupd (cdr (assoc -1 ob2)))
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    ); end progn
    (prompt "\n No dimension selected: ")
    ); end if
    ); end progn
    (setq flag 1); no point picked, exit
    ); end if
    ); end while

    (setvar "osmode" os1)
    (command "undo" "end")
    (princ)
    ); end function


    (defun lt-check(/ tb1 ltlist1)
    (setq tb1 (tblnext "ltype" T))
    (setq ltlist1 (list (cdr (assoc 2 tb1))))
    (while (setq tb1 (tblnext "ltype"))
    (setq ltlist1 (append ltlist1 (list (cdr (assoc 2 tb1)))))
    )
    (if (not (member "CENTER" ltlist1))
    (command "-linetype" "l" "CENTER" "ACAD.LIN" "")
    )
    )

    I had to change a few lines, but that helped out alot, and it works the way I wanted it to. Thanks.

    This raised a question now about dimension lines. When I select a short dim line, it changes it the way I want, but if it's short it doesn't look like a center line, and when I stretch it out it won't show either, so then I checked the dfx code, and it has a dotted pair to show center but it doesn't display as the center line type. So to solve that problem I was wondering if there is a way to check to see if it will show? Because if I can do that, then If it won't show then I can load a smaller scale center line type.

    Thanks for all the help.

    Tim
     
    T.Willey, May 20, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.