Lisp Question

Discussion in 'AutoCAD' started by John, Jan 15, 2005.

  1. John

    John Guest

    I have a lisp question for you guys.

    I am making a simple gcode generator. When I come to an arc I want to get
    the end point by clicking on it, then I want to click the arc so I can
    extract the radius information. I do this two step end then radius so that
    I make sure I'm getting the endpoint I want and not the one Autocad thinks
    it should be.

    Here is how I am doing it:
    (setq point (getpoint "Select Arc End:")) ;Prompt the
    user to specify the arcs end point
    (setq px (car point))
    ;Extract the X dimension
    (setq py (cadr point))
    ;Extract the Y dimension
    (setq pz (caddr point))
    ;Extract the Z dimension
    (setq enam (car (entsel "\nSelect ARC: "))) ;Prompt the
    user to select the arc
    (Setq pr (cdr (assoc 40 (entget(entlast))))) ;Extract the
    Radius dimension of selected arc

    The darned thing isn't working though. Well it does and it doesn't.
    When I select the arc with the entsel command it pretends to do something.
    I don't get a nil or an error.
    If I type in (entget(entlast)) I see whatever I edited last. If it was a
    line I see the line, if it was mtext I see that.

    If I type in (entsel "\nselect an object") then select an object, it still
    doesn't choose that object. It gives no error, just keeps hanging onto
    whatever I'd edited last.

    So tell me, what the heck is the deal? Is it some environment variable I
    need to set? Is my aperature to large? Why the heck will this stupid thing
    not entsel what the heck I'm clicking on.
    I even click on the arc using the midpoint osnap and it still
    (entget(entlast)) whatever I last edited.

    If you guys could help me with this I would be greatly appreciative. I'm
    sure I've left some important info out, if so let me know.

    Thanks,
    John
     
    John, Jan 15, 2005
    #1
  2. Try this:

    (setq pr (cdr (assoc 40 (entget enam))))


    HTH
    Juergen
     
    Jürgen Palme, Jan 15, 2005
    #2
  3. John

    John Guest

    Yup, that did it. I kept trying to do the same thing, but in my ignorance I
    kept trying to do it as:
    (setq pr (cdr (assoc 40 (entget(enam))))) I see now why I shouldn't have
    been putting teh variable into the parenthesis.

    Thanks for your help. It did the trick for me.

    John
     
    John, Jan 16, 2005
    #3
  4. You're welcome

    Juergen
     
    Jürgen Palme, Jan 16, 2005
    #4
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.