Distance with if/then

Discussion in 'AutoCAD' started by dth, Nov 4, 2004.

  1. dth

    dth Guest

    I am trying to write a routine that does different things depending on the
    length of the line. I am having the user pick two points:

    (setq pt1 (getpoint "\nPick first point..."))
    (if pt1 (setq pt2 (getpoint "\nPick end point...")))

    from here, I want the routine to act as follows:

    if the distance between PT1 and PT2 is 5" or greater, do this
    if the distance between PT1 and PT2 is less than 5", do something else

    Can someone point me in the right direction ?

    Thanks!
     
    dth, Nov 4, 2004
    #1
  2. Something like this....

    (initget 1) (setq p1 (getpoint "\npick first point"))
    (initget 1) (setq p2 (getpoint p1 "\npick second point"))

    (if (< (distance p1 p2) 5.0)
    (progn

    ; do stuff that is less than 5"

    )

    (progn

    ; do stuff that is greater than 5"

    )
    )
     
    Jason Piercey, Nov 4, 2004
    #2
  3. dth

    dth Guest

    I'll give it a try .....
    What about = 5"?
    also, what does (initget 1) do?
     
    dth, Nov 4, 2004
    #3
  4. The first test is less than 5, after that it is either
    equal to or greater than 5 by default.

    For the initget function see....

    Help -> Developer Help -> AutoLISP reference ->
    I functions -> iniget

    My comment should have read.

    ; do stuff that is greater than or equal to 5"
     
    Jason Piercey, Nov 4, 2004
    #4
  5. dth

    dth Guest

    Thanks for the help .... works great now!

    After I posted, I realized the stupidity of the equaled to 5" question ....
    I'll look up the initget
     
    dth, Nov 4, 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.