Get Entity, From Entity Name? (vanilla Lisp)

Discussion in 'AutoCAD' started by GTASteve, Oct 26, 2004.

  1. GTASteve

    GTASteve Guest

    Sounds simple, but is it?...

    I don't want the Entity List... I want the Entity.

    Explanation...
    I have a list, of entity name(s), extracted using (entnext), to obtain the last "x" number of polylines, added to a drawing. (note: they are all closed)

    So, next step, is to get the entity, so that I can use it in an AutoCAD command.

    E.g. Area. (example)
    (setq lastEnt (entnext)) ;get the entity name, of the last object
    (setq thisEntity (someMethodToGetEntityByName lastEnt))
    (command "_.AREA" "O" thisEntity)

    What I need, is that "some method to get entity by name"...

    Any Ideas?

    Ideally I'd like a vanilla LISP method... if not, a VLISP method, and failing that, a VBA method...
     
    GTASteve, Oct 26, 2004
    #1
  2. I don't understand what you are after. What
    do you need other than the ename?

    --
    Autodesk Discussion Group Facilitator



    last "x" number of polylines, added to a drawing. (note: they are all
    closed)
    failing that, a VBA method...
     
    Jason Piercey, Oct 26, 2004
    #2
  3. GTASteve

    Tom Smith Guest

    What I need, is that "some method to get entity by name"...

    Why not use the entity name? (command "_.AREA" "O" thisEntity) works as
    posted, as long as the entity has an area and is in the current space.

    Acad will just about always accept an entity name when it's prompting you
    for object selection.
     
    Tom Smith, Oct 26, 2004
    #3
  4. GTASteve

    GTASteve Guest

    Ahh, apparently I must have code issues elsewhere...

    this simple test works, but not my larger program...

    (defun c:aol (/)
    (setq lastEntName (entlast))
    (command "_.AREA" "O" lastEntName)
    (setq areaValue (getvar "AREA"))
    (princ areaValue)
    (princ)
    ) ;defun

    I'll go do some debugging!...

    Thanks
     
    GTASteve, Oct 26, 2004
    #4
  5. Try this:

    (defun ALE_LastEnt ( / EntNam OutVal)
    (and
    (setq OutVal (entlast))
    (while (setq EntNam (entnext OutVal))
    (setq OutVal EntNam)
    )
    )
    OutVal
    )

    (defun c:aol ( / )
    (command "_.AREA" "O" (ALE_LastEnt))
    (princ (getvar "AREA"))
    (princ)
    ) ;defun



    --

    Marc'Antonio Alessi
    http://xoomer.virgilio.it/alessi
    (strcat "NOT a " (substr (ver) 8 4) " guru.")

    --
     
    Marc'Antonio Alessi, Oct 26, 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.