Result not yet true

Discussion in 'AutoCAD' started by Adesu, Apr 22, 2004.

  1. Adesu

    Adesu Guest

    Dear Alls,
    I've create a program,after it run ,result of the program not yet true,as
    sample for scale 1:1 must be length = 380,width = 270,but result become
    380x380.
    Help me ,what a wrong in my lisp,and thanks for your help
    Best regards
    Ade Suharna


    ; Border is drawing area for drawing
    ; Design by Ade Suharna
    ; April 22, 2004
    ; Note of revision
    ; 1.
    ; 2.
    (defun c:bt ()
    (command "setvar" "cmdecho" "0")
    (prompt
    "\n 1/1 1/2 1/3 1/4 1/5 1/6 1/7.5 1/8 1/9 1/10")
    (if (= scale nil)(setq scale "choose size"))
    (princ "\nNOMINAL PAPER SCALE OF PAPER <")
    (princ scale)
    (prompt ">")
    (setq ans (getstring " "))
    (if (/= ans " ")(setq scale ans))
    (setq b1 (list 0 0)) ; to start set of point
    (setq b2 (list b2xx 0))
    (setq b3 (list (car b2)b2yy))
    (setq b4 (list 0 (cadr b3))) ; finnish set of point
    ;-----------------------------------------------------------
    (setq b2x (assoc scale A3)) ; start manipulation of data
    (setq b2xx (nth 3 b2x))
    (setq b2y (assoc scale A3))
    (setq b2yy (nth 5 b2y))
    ;------------------------------------------------------------
    (command ".line" b1 b2 b3 b4 "c"); draw of border
    (command "setvar" "cmdecho" "1")
    ;------------------------------------------------------------
    ; value this bellow indicated of coordinate
    ; coordinate b1 b2 b3 b4
    ; x y x y x y x y
    (setq A3 (quote(
    ("1/1" 0.0 0.0 380.0 0.0 380.0 270.0 0.0 270.0)
    ("1/2" 0.0 0.0 760.0 0.0 760.0 540.0 0.0 540.0)
    ("1/3" 0.0 0.0 1140.0 0.0 1140.0 810.0 0.0 810.0)
    ("1/4" 0.0 0.0 1500.0 0.0 1500.0 1100.0 0.0 1100.0)
    ("1/5" 0.0 0.0 1900.0 0.0 1900.0 1300.0 0.0 1300.0)
    ("1/6" 0.0 0.0 2280.0 0.0 2280.0 1620.0 0.0 1620.0)
    ("1/7.5" 0.0 0.0 2850.0 0.0 2850.0 2020.0 0.0 2020.0)
    ("1/8" 0.0 0.0 3040.0 0.0 3040.0 2160.0 0.0 2160.0)
    ("1/9" 0.0 0.0 3420.0 0.0 3420.0 2430.0 0.0 2430.0)
    ("1/10" 0.0 0.0 3800.0 0.0 3800.0 2700.0 0.0 2700.0)
    )
    )
    )
    (princ)
    ) ; end of program
     
    Adesu, Apr 22, 2004
    #1
  2. Adesu

    bob.at Guest

    Hi Ade,

    1.) replace (setq b2yy (nth 5 b2y)) by (setq b2yy (nth 6 b2y)), then you get the correct format.

    2.) I suppose there is something wrong in the order of your statements: first you use b2xx, but you assigne a value to it same lines later. The same is with variable A3. I think the correct order of statments should be:
    - define varible A3
    - ask for user input
    - define var. b2x, b2xx etc.
    - define points b1,b2,b3,b4
    - draw the line.

    3.) if you use (setvar "cmdecho" 0) instaead of (command "setvar" "cmdeche" "0") you also would not see this in the command line

    bob.at
     
    bob.at, Apr 22, 2004
    #2
  3. Adesu

    Adesu Guest

    Hi bob,
    Thanks a lot for your comment,but after this program revised as like
    no.1.),it program run and machine said ";error ;bad argument type :consp
    nil"
    what meaning it bob?
    Best regards
    Ade Suharna

    first you use b2xx, but you assigne a value to it same lines later. The same
    is with variable A3. I think the correct order of statments should be:
    "cmdeche" "0") you also would not see this in the command line
     
    Adesu, Apr 23, 2004
    #3
  4. Adesu

    bob.at Guest

    Hi Ade

    you should also do what i propose in no. 2). Otherwise var. A3 is not defined, (assoc scale A3) returns nil and (nth 3 nil) reports this error message.

    bob.at
     
    bob.at, Apr 23, 2004
    #4
  5. Adesu

    Adesu Guest

    Hi bob,now I post again this program,but I got problem to change var A3,can
    you give me a solution for this lisp,and thanks a lot for your comment
    Best regards
    Ade Suharna

    (defun c:bdr ()
    (command "setvar" "cmdecho" "0")
    (command "limmax" (list 6000 4000)".zoom" "a")
    ;--------------------------------------------------------------------
    (prompt "A0 A1 A2 A3 A4 A5")
    (if (= size nil)(setq size "choose size"))
    (princ "\nSELECT PAPER SIZE <")
    (princ size)
    (princ ">")
    (setq aks (getstring " "))
    (if (/= aks " ")(setq size aks))
    ;--------------------------------------------------------------------
    (prompt
    "1/1 1/2 1/3 1/4 1/5 1/6 1/7.5 1/8
    1/9 1/10")
    (if (= scale nil)(setq scale "choose scale"))
    (princ "\nSELECT SCALE SIZE <")
    (princ scale)
    (princ ">")
    (setq ans (getstring " "))
    (if (/= ans " ")(setq scale ans))
    ;---------------------------------------------------------------------
    (setq sizep (quote
    (("A0" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    ("A1" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    ("A2" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    ("A3" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    ("A4" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    ("A5" "1/1" "1/2" "1/3" "1/4" "1/5" "1/6" "1/7.5" "1/8" "1/9" "1/10")
    )))
    ;----------------------------------------------------------------------
    (setq A0 (quote
    (("1/1" 0.0 0.0 380.0 0.0 380.0 270.0 0.0 270.0) ;this data
    as sample (not yet update)
    ("1/2" 0.0 0.0 760.0 0.0 760.0 540.0 0.0 540.0)
    ("1/3" 0.0 0.0 1140.0 0.0 1140.0 810.0 0.0 810.0)
    ("1/4" 0.0 0.0 1500.0 0.0 1500.0 1100.0 0.0 1100.0)
    ("1/5" 0.0 0.0 1900.0 0.0 1900.0 1300.0 0.0 1300.0)
    ("1/6" 0.0 0.0 2200.0 0.0 2200.0 1620.0 0.0 1620.0)
    ("1/7.5" 0.0 0.0 2850.0 0.0 2850.0 2020.0 0.0 2020.0)
    ("1/8" 0.0 0.0 3040.0 0.0 3040.0 2160.0 0.0 2160.0)
    ("1/9" 0.0 0.0 3420.0 0.0 3420.0 2430.0 0.0 2430.0)
    ("1/10" 0.0 0.0 3800.0 0.0 3800.0 2700.0 0.0 2700.0)
    )))
    ;---------------------------------------------------------------------
    (setq A1 (quote
    (("1/1" 0.0 0.0 380.0 0.0 380.0 270.0 0.0 270.0) ;this data
    as sample (not yet update)
    ("1/2" 0.0 0.0 760.0 0.0 760.0 540.0 0.0 540.0)
    ("1/3" 0.0 0.0 1140.0 0.0 1140.0 810.0 0.0 810.0)
    ("1/4" 0.0 0.0 1500.0 0.0 1500.0 1100.0 0.0 1100.0)
    ("1/5" 0.0 0.0 1900.0 0.0 1900.0 1300.0 0.0 1300.0)
    ("1/6" 0.0 0.0 2200.0 0.0 2200.0 1620.0 0.0 1620.0)
    ("1/7.5" 0.0 0.0 2850.0 0.0 2850.0 2020.0 0.0 2020.0)
    ("1/8" 0.0 0.0 3040.0 0.0 3040.0 2160.0 0.0 2160.0)
    ("1/9" 0.0 0.0 3420.0 0.0 3420.0 2430.0 0.0 2430.0)
    ("1/10" 0.0 0.0 3800.0 0.0 3800.0 2700.0 0.0 2700.0)
    )))
    ;---------------------------------------------------------------------
    (setq A2 (quote
    (("1/1" 0.0 0.0 380.0 0.0 380.0 270.0 0.0 270.0) ;this data
    as sample (not yet update)
    ("1/2" 0.0 0.0 760.0 0.0 760.0 540.0 0.0 540.0)
    ("1/3" 0.0 0.0 1140.0 0.0 1140.0 810.0 0.0 810.0)
    ("1/4" 0.0 0.0 1500.0 0.0 1500.0 1100.0 0.0 1100.0)
    ("1/5" 0.0 0.0 1900.0 0.0 1900.0 1300.0 0.0 1300.0)
    ("1/6" 0.0 0.0 2200.0 0.0 2200.0 1620.0 0.0 1620.0)
    ("1/7.5" 0.0 0.0 2850.0 0.0 2850.0 2020.0 0.0 2020.0)
    ("1/8" 0.0 0.0 3040.0 0.0 3040.0 2160.0 0.0 2160.0)
    ("1/9" 0.0 0.0 3420.0 0.0 3420.0 2430.0 0.0 2430.0)
    ("1/10" 0.0 0.0 3800.0 0.0 3800.0 2700.0 0.0 2700.0)
    )))
    ;---------------------------------------------------------------------
    (setq A3 (quote
    (("1/1" 0.0 0.0 380.0 0.0 380.0 270.0 0.0 270.0)
    ("1/2" 0.0 0.0 760.0 0.0 760.0 540.0 0.0 540.0)
    ("1/3" 0.0 0.0 1140.0 0.0 1140.0 810.0 0.0 810.0)
    ("1/4" 0.0 0.0 1500.0 0.0 1500.0 1100.0 0.0 1100.0)
    ("1/5" 0.0 0.0 1900.0 0.0 1900.0 1300.0 0.0 1300.0)
    ("1/6" 0.0 0.0 2200.0 0.0 2200.0 1620.0 0.0 1620.0)
    ("1/7.5" 0.0 0.0 2850.0 0.0 2850.0 2020.0 0.0 2020.0)
    ("1/8" 0.0 0.0 3040.0 0.0 3040.0 2160.0 0.0 2160.0)
    ("1/9" 0.0 0.0 3420.0 0.0 3420.0 2430.0 0.0 2430.0)
    ("1/10" 0.0 0.0 3800.0 0.0 3800.0 2700.0 0.0 2700.0)
    )))
    ;----------------------------------------------------------------------
    (setq A4 (quote
    (("1/1" 0.0 0.0 260.0 0.0 260.0 184.7368 0.0 184.7368)
    ("1/2" 0.0 0.0 520.0 0.0 2600.0 369.4737 0.0 369.4737)
    ("1/3" 0.0 0.0 780.0 0.0 2600.0 554.2105 0.0 554.2105)
    ("1/4" 0.0 0.0 1040.0 0.0 2600.0 738.9474 0.0 738.9474)
    )))
    ;---------------------------------------------------------------------
    (setq A5 (quote
    (("1/1" 0.0 0.0 260.0 0.0 260.0 184.7368 0.0 184.7368) ;this
    data as sample (not yet update)
    ("1/2" 0.0 0.0 520.0 0.0 2600.0 369.4737 0.0 369.4737)
    ("1/3" 0.0 0.0 780.0 0.0 2600.0 554.2105 0.0 554.2105)
    ("1/4" 0.0 0.0 1040.0 0.0 2600.0 738.9474 0.0 738.9474)
    )))
    ;----------------------------------------------------------------------
    (setq sizep1 (assoc size sizep))
    (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A3)) ; from here I
    am not yet know how to change variable A3 to others (A1,A2,A3,A4,A5)
    (setq b2x (nth 3 sizep2))
    (setq b2y (nth 6 sizep2))
    ;----------------------------------------------------------------------
    (setq b1 (list 0 0))
    (setq b2 (list b2x 0))
    (setq b3 (list (car b2) b2y))
    (setq b4 (list 0 (cadr b3)))
    ;----------------------------------------------------------------------
    (command ".line" b1 b2 b3 b4 "c") ; stat draw of border
    (command ".setvar" "cmdecho" "1")
    (princ)
    (setq size nill scale nil ans nil aks nil b1 nil b2 nil b3 nil
    b4 nil sizep1 nil sizep2 nil b2x nil b2xx nil b2y nil
    b2yy nil) ; clean up
    ) ; end the program
    ;----------------------------------------------------------------------


    defined, (assoc scale A3) returns nil and (nth 3 nil) reports this error
    message.
     
    Adesu, Apr 26, 2004
    #5
  6. Adesu

    bob.at Guest

    Hi Ade,

    replace this line:
    (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A3)) ; from here I
    am not yet know how to change variable A3 to others (A1,A2,A3,A4,A5)

    with:
    (cond (= aks "A0") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A0))
    (= aks "A1") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A1))
    (= aks "A2") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A2))
    (= aks "A3") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A3))
    (= aks "A4") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A4))
    (= aks "A5") (setq sizep2 (assoc (nth (atoi (substr ans 3 3))sizep1) A5))
    )

    To ensure that you get now other input from the user, you should use an initget statemant:

    (initget "A0 A1 A2 A3 A4 A5")
    (setq aks (getstring " "))

    bob.at
     
    bob.at, Apr 26, 2004
    #6
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.