entsel and nentsel

Discussion in 'AutoCAD' started by Marcel Janmaat, Mar 5, 2004.

  1. Hello there,

    Within the same selection method, I sometimes want to obtain information
    from a block (entsel) and sometimes from a attribute (nentsel) within a
    block.

    Has anybody got a tip for me on how to approach this?

    Regards MJ
     
    Marcel Janmaat, Mar 5, 2004
    #1
  2. Marcel Janmaat

    Joe Burke Guest

    Marcel,

    Here's a method using ActiveX. You can do the same using entget and vanilla LISP.

    ;; assuming an insert is selected
    ;; returns either "AcDbAttribute" or "AcDbBlockReference"
    (defun c:test ( / ent vobj name ss )
    (setq ent (nentsel "Select attribute or block object: "))
    (setq vobj (vlax-ename->vla-object (car ent)))
    (setq name (vlax-get vobj 'ObjectName))
    (if (/= name "AcDbAttribute")
    (setq ss (ssget (cadr ent))
    vobj (vlax-ename->vla-object (ssname ss 0))
    )
    )
    (vlax-get vobj 'ObjectName) ;or return vobj
    ) ;end

    I've often wondered why there's not an entsel(p) function. Like entsel, but pass a
    point and return the primary object. Instead resort to (ssget <point>) as above.
    Maybe there's an easier way I'm not aware of.

    Joe Burke
     
    Joe Burke, Mar 5, 2004
    #2
  3. Marcel Janmaat

    Rudy Tovar Guest

    (defun c:testobj (/ ob ent)

    (setq ob (entsel "\nSelect Object: "))

    (if ob
    (progn
    (setq ent (nentselp (car (cdr ob))))
    (princ (entget (car ob)))
    (prompt "\n")
    (prompt "\n")
    (princ ent)
    )
    )
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi
     
    Rudy Tovar, Mar 5, 2004
    #3
  4. Marcel Janmaat

    John Uhden Guest

    You can use (setq Pick (nentselp)) with an optional prompt argument and without
    the optional [pt] argument.
    If there is an (nth 2 Pick) then that is the transformation matrix for a nested
    object and (last Pick) will return its parents as a list of entity names. Just
    be careful to inspect the parents since (nentselp) digs down into blocks within
    blocks, etc. (including xrefs).

    Of course if there isn't an (nth 2 Pick) then Pick is exactly the same as that
    returned by (entsel).
     
    John Uhden, Mar 7, 2004
    #4
  5. Marcel Janmaat

    Adesu Guest

    Hi Rudy ,what is different between entsel with nentselp?

    _$ (setq ob (entsel "\nSelect Object: "))

    (<Entity name: 14c7580> (4.38796 9.30149 0.0))

    _$ (setq ent (nentselp (car (cdr ob))))

    (<Entity name: 14c7580> (4.38796 9.30149 0.0))
     
    Adesu, Nov 8, 2004
    #5
  6. Marcel Janmaat

    John Uhden Guest

    Read the rest of the thread back in March 2004.
     
    John Uhden, Nov 9, 2004
    #6
  7. Marcel Janmaat

    Adesu Guest

    ??

     
    Adesu, Nov 9, 2004
    #7
  8. Marcel Janmaat

    Anne Brown Guest

    Anne Brown, Nov 9, 2004
    #8
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.