+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    joker
    Guest

    Default adding values to points in alisp

    Registered forum members do not see this ad.

    Could someone tell me how to add values to points. I want to make a square using a user input first point. How would I create a second point by adding values to the first point?

  2. #2
    Super Member
    Using
    AutoCAD 2007
    Join Date
    Aug 2003
    Location
    Livingston, Scotland
    Posts
    995

    Default

    after you have the first point, you then extract the X & Y values (and possibly Z), then you add the figures you need to concoct the next point. which figures all depend upon which way you want to draw the rectangle from the first point.
    I think you need to provide a little bit more info here
    ResourceCAD.... the Resource for your CAD Solutions

  3. #3
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,083

    Default

    There are several ways to approach this:

    (setq p1 '(2 3 0))

    maybe:

    (setq p2 (mapcar '+ p1 '(2 2 0)))

    or:

    (setq ap (lambda (p s)
    (list (+ (car p) s)
    (+ (cadr p) s))

    (setq p2 (ap p1 2))

    -David
    R12 (Dos) - A2K

  4. #4
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    804

    Default

    Here are some more examples.
    Lets start at point 2,2 and go around a square.

    Code:
    (setq x 2
          y 2
    )
    
    (setq p1 (list x y)
          p2 (list x (+ y 5))
          p3 (list (+ x 5) (+ y 5))
          p4 (list (+ x 5) y)
    )
    
    (command "._pline" p1 p2 p3 p4 p1 "")
    Lets go from p3 to 10,10
    We need to add 3 to x & y
    Code:
    (setq p5 (list (+ (car p3) 3)(+ (cadr p3) 3)))

  5. #5
    Senior Member Dommy2Hotty's Avatar
    Using
    AutoCAD 2007
    Join Date
    Mar 2004
    Location
    Homer Glen, IL
    Posts
    350

    Default

    Registered forum members do not see this ad.

    There's always "getcorner"
    AutoCAD 2005
    ADT 2005

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts