error: bad argument value

Discussion in 'AutoCAD' started by Adesu, May 25, 2004.

  1. Adesu

    Adesu Guest

    Can someone's tell to me,what this " error: bad argument value: AutoCAD
    command: #<SUBR @01d551e0 SSGET>"
    Best regards
    Ade Suharna


    Command: (c:are)
    CLICK LOCATION FOR OBJECT:
    ENTER LENGTH OF BOX: 20
    ENTER WIDTH OF BOX: 17
    1 loop extracted.
    1 Region created.
    ; error: bad argument value: AutoCAD command: #<SUBR @01d551e0 SSGET>
    Select objects:
    Area = 340.0000, Perimeter = 74.0000
    ;---------------------------------------------------------------------------
    ---------
    ; Are is stand for to calculation of area a box
    ; Design by Ade Suharna
    ; May 21, 2004
    (defun c:are ()
    (command "setvar" "cmdecho" "0")
    (command "limmax" (list 120 80))
    ;----------------------------------------------------
    (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT: "))
    (setq len (getdist "\nENTER LENGTH OF BOX: "))
    (setq wid (getdist "\nENTER WIDTH OF BOX: "))
    ;----------------------------------------------------
    (setq p1 (list (- (car loc) (/ len 2))
    (- (cadr loc) (/ wid 2))))
    (setq p2 (polar p1 (angtof "0") len))
    (setq p3 (polar p2 (angtof "90") wid))
    (setq p4 (polar p3 (angtof "180") len))
    (setq pa (list (- (car p1) len)(- (cadr p1) wid)))
    (setq pb (list (+ (car p3) len)(+ (cadr p3) wid)))
    ;----------------------------------------------------
    (command ".line" p1 p2 p3 p4 "c" "")
    (command ".region" "w" pa pb "")
    (command ".area" "o" ssget )
    ;----------------------------------------------------
    (command "setvar" "cmdecho" "1")
    (princ)
    )
     
    Adesu, May 25, 2004
    #1
  2. Adesu

    Jürg Menzi Guest

    Adesu

    For A2k+:

    ; Are is stand for to calculation of area a box
    ; Design by Ade Suharna
    ; May 21, 2004
    (defun c:are ( / loc len wid p1 p2 p3 p4 CurObj)
    (vl-load-com) ;Initialize ActiveX
    (setvar "cmdecho" 0) ;setvar, not command
    ;;; (command "limmax" (list 120 80)) ;Why 'limmax'?
    ;----------------------------------------------------
    (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT: ")
    len (getdist loc "\nENTER LENGTH OF BOX: ")
    wid (getdist loc "\nENTER WIDTH OF BOX: ")
    ;----------------------------------------------------
    p1 (list (- (car loc) (/ len 2.0))
    (- (cadr loc) (/ wid 2.0))
    )
    p2 (polar p1 0 len)
    p3 (polar p2 (/ pi 2) wid) ;(/ pi 2) = 90°
    p4 (polar p3 pi len) ;pi = 180°
    )
    ;----------------------------------------------------
    ;;; (command ".line" p1 p2 p3 p4 "c" "") ;"" recalls line command
    ;;; (command ".region" "w" pa pb "")
    ;;; (command ".area" "o" ssget ) ;ssget without '()' gives the error
    ;The easy way to get the infos:
    (command "_.pline" p1 p2 p3 p4 "_clo") ;use pline instead
    (setq CurObj (vlax-ename->vla-object (entlast)))
    (princ
    (strcat
    "\nPerimeter: " (rtos (vla-get-Length CurObj))
    ", Area: " (vla-get-Area CurObj)
    )
    )
    ;----------------------------------------------------
    (setvar "cmdecho" 1) ;setvar, not command
    (princ)
    )



    Cheers
     
    Jürg Menzi, May 25, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi Menzi,setting limmax in my cad is 12.0000,9.0000,I always create a lisp
    still simple program,not yet to "(vl-load-com)",and thanks a lot for your
    suggest
    Best regards
    Ade Suharna
     
    Adesu, May 25, 2004
    #3
  4. Adesu

    DEVItG Guest

    Hi Adesu , why not to get the area as the multiplication as (setq area ( *
    len wid) ).
    But if you want to do on the other way :
    And if you use the _RECTANG command you only need only two points
    (command "_rectang p1 p3 )
    and then, with this
    (command "_region" "L" "")
    You will get the region in a touch , "L" stand for Last Enty created
    (comannd "area" "o" "L") again the area object look for the Last
    now to show the area , you need to retrive it form AREA sysvar
    (setq are (getvar "area")
    (princ are)


    BTW

    The error comes from

    (command ".area" "o" ssget ) ssget


    Please see this page.

    http://courses.home.att.net/autolisp/

    Afra lisp is of course a good place to learn LISP , but this one is for
    kindergarden pupils

    Hope it help









    SERVICIOS TECNICOS Gabriel CALÓS DE VIT Ducasse 948 CORDOBA ARGENTINA TE
    0351-472-2677 CELULAR 156-575-497
    (command ".area" "o" "l" ) ; get the area to be stored on sysvars area
    (setq are (getvar "area")) ; retrieve the area value to are

    (princ are) ;show the are
     
    DEVItG, May 26, 2004
    #4
  5. Adesu

    Adesu Guest

    Hi devitg,thanks a lot for your suggest,yes I've forgot to calculation by
    (setq area (* lin wid))
     
    Adesu, May 26, 2004
    #5
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.