known SY

Discussion in 'AutoCAD' started by John Callaway, Sep 4, 2009.

  1. Is there a lisp routine available to draw either a circle or rectangle
    with a known square yard area?

    JPC
     
    John Callaway, Sep 4, 2009
    #1
  2. John Callaway

    strawberry Guest

    A routine like this would draw a circle at whatever size and position
    specified (in your preferred working units):

    ; ----- CTEST.LSP -----
    ; Draw circles by area

    (defun C:CTEST()
    (setq ar (getreal "Area? "))
    (setq pt (getpoint "Centerpoint?"))
    (setq rad (sqrt (/ ar pi)))
    (command "circle" pt rad)
    (princ)
    )

    Rectangles are a little trickier. Do you have some way of relating the
    length of the rectangle to its width?
     
    strawberry, Sep 6, 2009
    #2
  3. Strawberry,
    Thanks, that is good for a circle area. I tried to set my units to 9'
    (ddunits) so I can get square yards when I run your lisp, but I am
    having problems. Can you guide me how to set my units to 9'?

    JPC
     
    John Callaway, Sep 6, 2009
    #3
  4. John Callaway

    Tom Berger Guest

    Am Fri, 04 Sep 2009 18:28:35 -0400 schrieb John Callaway:
    You can do that with Geomcal in AutoCAD or with BricsCAD with my Geomcal
    compatible CADCAL application. Geomcal.arx is part of the AutoCAD
    distribution, simply type 'CAL a´t the command prompt or when asked top
    enter a point inside a command.

    CAL (either from Geomcal or from CADCAL) let's you enter mathematical
    expressions that can be used as input to commands. When your area is 123,
    then you could draw a rectangle from any startpoint, and when asked for the
    opposite point you could enter:
    'CAL
    In this expression '@' stands for the last entered point, in this case this
    is the first point of your rectangle. And the rest is self explaining, as I
    hope.

    You can also use Lisp variables in your expressions:
    (setq ar 123)
    'CAL
    If you are working with BricsCAD then you can download CADCAL from
    http://www.archtools.de/cadcal.des
     
    Tom Berger, Sep 6, 2009
    #4
  5. John Callaway

    strawberry Guest

    Hi John,

    Try to avoid top-posting. My provider handles it OK but it drives some
    people around here absolutely bananas.

    You don't really need to set your units 'to' anything. Although
    AutoCAD supports conventions for inputting measurements like [ ' ] for
    feet and [ " ] for inches, don't be fooled, AutoCAD really has no
    interest in what your preferred units are. The issue only arises when
    working with data provided by others. In your case, it seems like
    you're working on a drawing drawn in 'feet'. Because there are 3 feet
    in a yard just scale the drawing by 1/3rd. If the drawing's in inches
    just scale it by 1/(3*12) = 1/36. When you're done using the lisp
    command, just scale it back again - or at least make it very apparent
    in the drawing that that's what you've done!

    Also, I forgot to mention that AutoCAD's RECTANGLE command has of
    course already got a feature built-in for drawing rectangles based
    upon their area and a known length or width.
     
    strawberry, Sep 6, 2009
    #5

  6. Strawberry,
    I posted this below your message, I didn't realize it made any
    difference and do apologize. Your lisp works fine. Would it be
    possible to tweak it?
    2 issues
    1) Could you explain further how I can insert a known area in square
    yards when I use the rectang command?
    2) Since I know what my area is in square yards and there are 1296 sq
    inches in a square yard, could you modify the lisp you sent to prompt
    for an "area SY"?

    JPC
     
    John Callaway, Sep 7, 2009
    #6
  7. John Callaway

    strawberry Guest

    1.
    ; ----- RECTEST.LSP -----
    ; Draw rectangles by area (in square yards) and one known length (in
    yards)

    (defun C:RECTEST()
    (setq ar (getreal "AreaSY? "))
    (setq ar (* ar 1296))
    (setq len (getreal "LengthY? "))
    (setq len (* len 36))
    (setq pt (getpoint "Cornerpoint?"))
    (command "rectangle" pt "a" ar "l" len )
    (princ)
    )

    2.
    ; ----- CTEST.LSP -----
    ; Draw circles by area (in square yards)

    (defun C:CTEST()
    (setq ar (getreal "AreaSY? "))
    (setq ar (* ar 1296))
    (setq pt (getpoint "Centerpoint?"))
    (setq rad (sqrt (/ ar pi)))
    (command "circle" pt rad)
    (princ)
    )
     
    strawberry, Sep 7, 2009
    #7
  8. John Callaway

    strawberry Guest

    BTW, although I'm not the world's worst lisp programmer, I'm
    definitely a contender for that prize, so feel free to have a go at
    this stuff yourself! :)
     
    strawberry, Sep 7, 2009
    #8
  9. John Callaway

    Tom Berger Guest

    Am Sun, 6 Sep 2009 15:08:46 -0700 (PDT) schrieb strawberry:
    And please try to remove everything from the original posting that is not
    necessary for your reply :)

    Citing parts of the posting to which you reply is only necessary for one
    thing: to enable the reader of your posting to understand your reply.
     
    Tom Berger, Sep 7, 2009
    #9

  10. The circSY lisp works great! However I have trouble with the
    rectangSY lisp. Is there a way to just have the prompt ask only for
    the Square Yards? When I enter the sy it then asks for one corner then
    another which then will not be the square yards I entered.
    I cleaned out the rest of the thread to improve my protocol.

    JPC
     
    John Callaway, Sep 8, 2009
    #10
  11. John Callaway

    strawberry Guest

    It works fine on my machine (XP running AutoCAD2008). Your version
    must be a little different.
    Run through the rectang command (using the area option - and not using
    my rectest routine) and post the results here, e.g.:

    Command: rec RECTANG
    Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/
    Width]: [User clicks point on screen]
    Specify other corner point or [Area/Dimensions/Rotation]: a
    Enter area of rectangle in current units <129600.0000>: 100

    Calculate rectangle dimensions based on [Length/Width] <Length>: l

    Enter rectangle length <360.0000>: 10
     
    strawberry, Sep 8, 2009
    #11
  12. Strawberry,
    I should have stated before, I am running Version R14. There
    is no area option for the second corner.

    JPC
     
    John Callaway, Sep 8, 2009
    #12
  13. John Callaway

    strawberry Guest

    14!?!? That's from 12 years ago! Pause while I get doey-eyed and
    misty. Still, it was an excellent program and, unless you plan to work
    in 3d, probably the only version you'd ever need.

    The lisp can still be adjusted to work. I just need to remember how to
    do vector maths in lisp. It would still be useful to see what the
    command 'looks' like though. Is it just "select first corner, select
    second corner' or is/was there more to it than that?

    Also, can you define the relationship between the length of the
    rectangle and its width, or is its width, say, a constant?
     
    strawberry, Sep 9, 2009
    #13
  14. Strawberry,

    The following is from my R14

    Command: rectest
    AreaSY? 1052
    LengthY? 100
    Cornerpoint?rectangle
    Chamfer/Elevation/Fillet/Thickness/Width/<First corner>:
    Other corner: a
    Invalid 2D point.
    error: Function cancelled
    (COMMAND "rectangle" PT "a" AR "l" LEN)
    (C:RECTEST)

    Other corner:

    The lisp creates a rectangle but I have no control over the SY
    even though it first asks for Area SY input. It continues on to ask
    for both corner points which essentially negates the first Area SY
    input. If it only asked me for the SY area and then created the
    rectangle using one corner, it would be fine.
    Lengths & widths are not factors at all. All I need is to be
    able to plug in a known SY quantity. I am converting existing
    contracts to a different format using different unit factors. The
    circle lisp has helped greatly. It would be perfect if I could also
    use the rectang lisp to create a retangle with a known quantity of
    square yards.


    JPC
     
    John Callaway, Sep 9, 2009
    #14
  15. John Callaway

    strawberry Guest

            Lengths & widths are not  factors at all.

    !?!

    So you'd be just as happy with a square?
     
    strawberry, Sep 9, 2009
    #15
  16. I never really thought about that, but yes, that is correct.
     
    John Callaway, Sep 9, 2009
    #16
  17. John Callaway

    strawberry Guest

    ; ----- SQUARETEST.LSP -----
    ; Draw rectangles by area and one known length

    (defun C:SQUARETEST()

    ; Degrees to Radians
    (defun dtr (a)(* pi (/ a 180)) )

    ; Get area in square yards
    (setq ar (getreal "AreaSY? "))

    ; Convert to square inches
    (setq ar (* ar 1296))

    ; Get first point (bottom left-hand corner of square)
    (setq p1 (getpoint "\nfirst corner of square: "))

    ; Calculate second point (top right-hand corner of square)
    (setq p2 (polar p1 (dtr 45.0) (sqrt (+ ar ar))))

    ; Execute
    (command "rectangle" p1 p2)

    ; Exit quietly
    (princ)
    )
     
    strawberry, Sep 9, 2009
    #17
  18. John Callaway

    strawberry Guest

    ; ----- SQUARETEST.LSP -----
    ; Draw rectangles by area

    (defun C:SQUARETEST()

    ; Degrees to Radians
    (defun dtr (a)(* pi (/ a 180)) )

    ; Get area in square yards
    (setq ar (getreal "AreaSY? "))

    ; Convert to square inches
    (setq ar (* ar 1296))

    ; Get first point (bottom left-hand corner of square)
    (setq p1 (getpoint "\nfirst corner of square: "))

    ; Calculate second point (top right-hand corner of square)
    (setq p2 (polar p1 (dtr 45.0) (sqrt (+ ar ar))))

    ; Execute
    (command "rectangle" p1 p2)

    ; Exit quietly
    (princ)
    )
     
    strawberry, Sep 9, 2009
    #18
  19. John Callaway

    strawberry Guest

    Hm, this solution is subject to floating point errors. It will perform
    oddly when drawing far from 0,0
     
    strawberry, Sep 9, 2009
    #19
  20. John Callaway

    strawberry Guest

    I think this will perform better...
    ; ----- SQUARETEST.LSP -----
    ; Draw squares by area

    (defun C:SQUARETEST()

    ; Degrees to Radians
    (defun dtr (a)(* pi (/ a 180.0)) )

    ; Get area in square yards
    (setq ar (getreal "AreaSY? "))

    ; Convert to square inches
    (setq ar (* ar 1296))

    ; Get first point (bottom left-hand corner of square)
    (setq p1 (getpoint "\nfirst corner of square: "))

    ; Calculate second point (top right-hand corner of square)
    (setq p2 (polar p1 (dtr 45.0) (sqrt (+ ar ar))))

    ; Execute
    (command "rectangle" p1 p2)

    ; Exit quietly
    (princ)
    )
     
    strawberry, Sep 9, 2009
    #20
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.