Can anyone tell me how to add specific coordinates?

Discussion in 'AutoCAD' started by Big 'D', May 20, 2004.

  1. Big 'D'

    Big 'D' Guest

    I have a routine (see below) to draw a rectangle and ask to add a break symbol. I have it set up for user specified point. I would like to set the default size to .5,1 for the rectangle but do not know how because of the way I am locating the point for the break.
    Would someone offer advise, please?
    Thank you,
    D

    (initget 1)
    (setq pt1 (getpoint "First corner: "))
    (initget 1)
    (setq pt2 (getcorner pt1 "Opposite corner: "))

    (command "rectangle" pt1 pt2)

    (if (< (cadr pt1) (cadr pt2)) (setq ybase (cadr pt1)) (setq ybase (cadr pt2)))

    (setq xmidbase (/ (+ (car pt1) (car pt2)) 2))

    (initget "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (/= breakanswer "No")

    (progn

    (command "break" "non" (list (- xmidbase (/ 0.06 2)) ybase) "non" (list (+ xmidbase (/ 0.06 2)) ybase))

    (command "insert" "G:/Acad2000/cadstd/symlib/DC-10/bko" "non" (list xmidbase ybase) "1" "1" "0")

    );progn
     
    Big 'D', May 20, 2004
    #1
  2. Try this:

    (defun C:Test (/ pt1 pt2)
    (initget 1)
    (setq pt1 (getpoint "First corner: ")
    pt2 (cond ((getcorner pt1 "Opposite corner <@0.5,1.0>: "))
    ((mapcar '+ pt1 '(0.5 1.0)))))
    (command "._rectangle" pt1 pt2)
    (princ))


    --
    R. Robert Bell


    I have a routine (see below) to draw a rectangle and ask to add a break
    symbol. I have it set up for user specified point. I would like to set the
    default size to .5,1 for the rectangle but do not know how because of the
    way I am locating the point for the break.
    Would someone offer advise, please?
    Thank you,
    D

    (initget 1)
    (setq pt1 (getpoint "First corner: "))
    (initget 1)
    (setq pt2 (getcorner pt1 "Opposite corner: "))

    (command "rectangle" pt1 pt2)

    (if (< (cadr pt1) (cadr pt2)) (setq ybase (cadr pt1)) (setq ybase (cadr
    pt2)))

    (setq xmidbase (/ (+ (car pt1) (car pt2)) 2))

    (initget "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (/= breakanswer "No")

    (progn

    (command "break" "non" (list (- xmidbase (/ 0.06 2)) ybase) "non" (list
    (+ xmidbase (/ 0.06 2)) ybase))

    (command "insert" "G:/Acad2000/cadstd/symlib/DC-10/bko" "non" (list
    xmidbase ybase) "1" "1" "0")

    );progn
     
    R. Robert Bell, May 20, 2004
    #2
  3. Big 'D'

    BillZ Guest

    You could also simplifiy your break point.

    If I'm assuming the break is always at the bottom midpoint of the rectangle.

    (setq xmidbase (polar pt1 0 (* (distance pt1 (list (car pt2)(cadr pt1))) 0.5)) ;mid point of base
    )

    (initget 1 "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (= breakanswer "Yes")

    (progn

    (command "break" (entlast) xmidbase "@")

    Bill
     
    BillZ, May 20, 2004
    #3
  4. Big 'D'

    Big 'D' Guest

    Robert,
    The code you sent worked. thank you for that. I am still having difficulty adding the break symbol. The prompt comes up but asks me to select an object to break instead of adding the brk block as it did before I set the default size. Any clue?
    D
     
    Big 'D', May 20, 2004
    #4
  5. Big 'D'

    Big 'D' Guest

    What I am trying to do is break the bottom line at the right distance to accommodate the insertion of block "brk". The break symbol I insert will always be on the bottom and in the middle if I choose not to use the default rectangle size.
    Thanks for helping me through this, guys.
    D
     
    Big 'D', May 20, 2004
    #5
  6. Big 'D'

    BillZ Guest

    Ah, a distance would require 2 points on the break.

    (setq dis1 0.3 ;; your half distance, I think.
    pt3 (polar pt1 0 (* (distance pt1 (list (car pt2)(cadr pt1))) 0.5)) ;mid point of base
    midbase1 (polar pt3 pi dis1) ;half distance at 180d.
    midbase2 (polar pt3 0 dis1) ;half distance at 0d.
    )

    (initget 1 "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (= breakanswer "Yes")

    (progn

    (command "break" (entlast) midbase1 midbase2 )


    Bill
     
    BillZ, May 20, 2004
    #6
  7. Big 'D'

    BillZ Guest

    D,

    That first break suggestion may be the trouble.

    Command:break
    Select object:
    Specify second break point or [First point]:
    Which would require a "F" in the command line.

    (command "break" (entlast) "f" xmidbase "@")

    See my other reply about 2 point breaks.

    Bill
     
    BillZ, May 20, 2004
    #7
  8. Big 'D'

    Big 'D' Guest

    Bill,
    I have gotten myself so confused. This is driving me crazy!
    Below is a variation of this routine that works. All I want to do is add the ability to return a default size of 0.16,-1.0 for the rectangle, break the bottom line (.06 - .03 each side of the center) and insert the block called 'brk' in the break. Wouild you help again please? earlier I tried to take out part of the lisp to send - then when I tried to put it back together - I messed up - someplace....HELP!
    Code:
    ; Define the function (the program).
    (defun c:pb ( / OLDCE OLDERR OLDTE)
    ; Save the current value of cmdecho then redefine it.
    (setq OLDCE (getvar "cmdecho"))
    (setvar "cmdecho" 1)
    ; Save the current value of texteval then set it to 1
    (setq OLDTE (getvar "texteval"))
    (setvar "texteval" 1)
    ; Save the current value of the error handling subroutine then redefine it.
    (setq OLDERR *error*)
    (defun *error* (errmes)
    (princ (strcat "\nExecution of ADD halted by the following error: " ERRMES))
    (setvar "cmdecho" OLDCE)
    (setq *error* OLDERR)
    (prin1)
    )
    ;(setq *error* nil)
    ; NOTE: to turn error handling off, erase the semicolon in the line above.

    ; Input to AutoCAD's command line.
    (command
    "layer"
    "s"
    "obj"
    ""
    )

    (initget 1)
    (setq pt1 (getpoint "First corner: "))
    (initget 1)
    (setq pt2 (getcorner pt1 "Opposite corner: "))

    (command "rectangle" pt1 pt2)

    (if (< (cadr pt1) (cadr pt2)) (setq ybase (cadr pt1)) (setq ybase (cadr pt2)))

    (setq xmidbase (/ (+ (car pt1) (car pt2)) 2))

    (initget "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (/= breakanswer "No")

    (progn

    (command "break" "non" (list (- xmidbase (/ 0.06 2)) ybase) "non" (list (+ xmidbase (/ 0.06 2)) ybase))

    (command "insert" "G:/Acad2000/cadstd/symlib/DC-10/bko" "non" (list xmidbase ybase) "1" "1" "0")

    );progn

    (command "osnap"
    "none"
    "osnap"
    "nea"
    )
    )
     
    Big 'D', May 20, 2004
    #8
  9. Big 'D'

    BillZ Guest

    Try this:

    (defun *error* (errmes)
    (princ (strcat "\nExecution of ADD halted by the following error: " ERRMES))
    (setvar "cmdecho" OLDCE)
    (setq *error* OLDERR)
    (prin1)
    )
    ;-----;
    (defun c:pb ( / OLDCE OLDERR OLDTE)
    ; Save the current value of cmdecho then redefine it.
    (setq OLDCE (getvar "cmdecho"))
    (setvar "cmdecho" 1)
    ; Save the current value of texteval then set it to 1
    (setq OLDTE (getvar "texteval"))
    (setvar "texteval" 1)
    ; Save the current value of the error handling subroutine then redefine it.
    (setq OLDERR *error*)

    ;(setq *error* nil)
    ; NOTE: to turn error handling off, erase the semicolon in the line above.

    ; Input to AutoCAD's command line.

    ;(command "layer" "s" "obj" "")

    (initget 1)
    (setq pt1 (getpoint "First corner: ")
    pt2 (cond ((getcorner pt1 "Opposite corner <@0.5,1.0>: "))
    ((mapcar '+ pt1 '(0.5 1.0))
    )
    )
    )

    (command "rectangle" pt1 pt2)

    (if (< (cadr pt1) (cadr pt2))
    (setq ybase (cadr pt1))
    (setq ybase (cadr pt2))
    )

    (setq xmidbase (/ (+ (car pt1)(car pt2)) 2)
    )

    (initget 1 "Yes No")
    (setq breakanswer (getkword "\nDo you want a break [Yes/No] <Yes>: "))

    (if (/= breakanswer "No")

    (progn

    (command "break" (entlast) (list (- xmidbase (/ 0.06 2)) ybase) (list (+ xmidbase (/ 0.06 2)) ybase))

    ;(command "insert" "G:/Acad2000/cadstd/symlib/DC-10/bko" "non" (list xmidbase ybase) "1" "1" "0")

    );progn

    )
    )

    I'll be back tommorro.

    Bill
     
    BillZ, May 20, 2004
    #9
  10. Big 'D'

    Big 'D' Guest

    Thanks guys, it is going now and I still have some hair left!
    D
     
    Big 'D', May 20, 2004
    #10
  11. Big 'D'

    David Doane Guest

    Looks good, except since you give a default of <Yes> for the break perhaps
    removing the "1" control bit for Initget would allow answering it with the
    space bar or Enter key.rather than specifically hitting the "Y" key.

    Also, using a couple of "non"s would eliminate problematic Osnap settings,
    specifically "End", ie:

    (command "break" (entlast) "non" (list (- xmidbase (/ 0.06 2)) ybase) "non"
    (list (+ xmidbase (/ 0.06 2)) ybase))

    Didn't mean to butt in. Just commenting.
    --
    Dave D



    error handling subroutine then redefine it.
    off, erase the semicolon in the line above.
    (+ xmidbase (/ 0.06 2)) ybase))
     
    David Doane, May 21, 2004
    #11
  12. Big 'D'

    David Doane Guest

    And of course a (princ) at the end. <heh, heh>
     
    David Doane, May 21, 2004
    #12
  13. This, and several subsequent posts that continue the
    (list (car pt2)(cadr pt1))
    language, will only work as intended IF "pt1" is the LOWER of the two points
    picked. To give the user the option of picking whichever corners they want
    in any relative position, you need something like my original comparison of
    y coordinates (which I'm glad to see some subsequent posts have re-adopted)
    to make sure you're breaking the BOTTOM edge. [Even though it was
    originally on a thread titled differently, I was the originator of the terms
    "ybase" and "xmidbase" that still survive into these variants.] And I still
    say you don't need "initget" -- just ask for a Y/N answer with Y as the
    default, and use "strcase" to force the user input to uppercase. If that
    results in "N", you don't break it. (See my earlier one, if you can find it
    now.)
    Also, wouldn't the break command at the end break it in two without making a
    gap?

    Kent Cooper, AIA


    0.5)) ;mid point of base <<NO, see, that's the midpoint of the horizontal
    edge that pt1 is one end of, which could be the top OR the bottom.
     
    Kent Cooper, AIA, May 21, 2004
    #13
  14. Big 'D'

    BillZ Guest

    Didn't mean to **** in. Just commenting.

    No problem.
    I was trying some things and didn't change some things to the original.
    I removed the "non"'s to test and..well.... :)

    Bill
     
    BillZ, May 21, 2004
    #14
  15. Big 'D'

    BillZ Guest

    Correct,
    I didn't understand that part of the code so tried something that I thought might work but was thinking of a LL to UR pick.

    Mis-read the the Y/N snip and thought it would give problems without the (initget 1.

    I gotta quite staying up late watching those BB championships. :)

    Bill
     
    BillZ, May 21, 2004
    #15
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.