quick lisp query

Discussion in 'AutoCAD' started by David Bethel, Jul 7, 2003.

  1. David Bethel

    David Bethel Guest

    Step thru the insert & attrib definitions until SEQEND

    SEQEND -2 points to the main insert ename.

    -David
     
    David Bethel, Jul 7, 2003
    #1
  2. David Bethel

    Jamie Duncan Guest

    I have a routine that uses nentsel t9o pick an attribute within a block, I
    now wish to change the layer of the block that contains this attribute:

    I could do a ssget through the insertion point of the attribute
    if there was an entprev I could step backwards and obtain the block name
    What is the best way to handle this using plain vanilla lisp?

    Thanks


    Jamie Duncan

    Consulting - If you're not part of the solution, there's good money in
    prolonging the problem.
     
    Jamie Duncan, Jul 7, 2003
    #2
  3. ; [ename] - attrib entity name
    ; return: insert entity name in which [ename] is defined
    ; (attribInsert (car (nentsel "\nselect an attribute: ")))
    (defun attribInsert (ename / data)
    (while
    (and
    (setq ename (entnext ename))
    (setq data (entget ename))
    (/= "SEQEND" (cdr (assoc 0 data)))
    )
    )
    (cdr (assoc -2 data))
    )
     
    Jason Piercey, Jul 7, 2003
    #3
  4. David Bethel

    Jamie Duncan Guest

    Duh! I feel dumb.

    Thsnks for reminding me!

    --


    Jamie Duncan

    Consulting - If you're not part of the solution, there's good money in
    prolonging the problem.
     
    Jamie Duncan, Jul 7, 2003
    #4
  5. Jason,
    thanks for correction,
    just checked - for ALL insert if You DO NOT pick attribute
    uu
     
    Ursus Uziemblo, Jul 7, 2003
    #5
  6. David Bethel

    Mike Weaver Guest

    Jamie,
    Here is a function that returns the insert without having to cycle through
    all the entities in the block. It takes one argument, either an entity name
    for an attribute object, or an active-x attribute object. The return value
    will be an ename if the argument was an ename, otherwise a vla-object
    IAcadBlockReference is returned:

    (defun AttToBlockRef( ;Given an attribute entity, returns the block
    reference
    objAtt ;attribute entity or object
    /
    objAtt WasEname OwnerID objDoc objOwner
    )
    (if (= 'ENAME (type objatt))
    (setq
    objAtt (vlax-ename->vla-object objAtt)
    WasEname T
    )
    )
    (setq
    OwnerId (vla-get-ownerid objAtt)
    objDoc (vla-get-document objAtt)
    objOwner (vlax-invoke-method objDoc 'ObjectIDToObject OwnerId)
    )
    (if WasEname (vlax-vla-object->ename objOwner) objOwner)
    )

    Mike Weaver
     
    Mike Weaver, Jul 7, 2003
    #6
  7. David Bethel

    Doug Broad Guest

    Jamie,
    Another technique is to use ssget on the pick point returned by
    nentsel as the 2nd element of the return list:
    (setq block_ename (ssname (ssget (cadr (nentsel "\nSelect attribute: "))) 0))

    Of course you would have to handle errors in case the user failed to
    select anything or did not select an attribute. Something like the
    following c:test which returns the ename of the block or nil with
    messages.

    I can't imagine a situation where ssget would not return the correct
    block(but my imagination is not what it used to be :)
    Jason's function would be foolproof if there was a check
    to determine: 1) that anything had been selected and 2) the entity
    was an ATTRIB before proceeding to the search for the SEQEND.

    (defun c:test ()
    (COND
    ((not (setq nent (nentsel "\nSelect attribute: ")))
    (princ "\nNo object selected: "))
    ((/= (CDR(ASSOC 0 (setq attrib_data (entget (car nent))))) "ATTRIB")
    (princ "\nAttribute selected was not an attribute: "))
    (t
    (ssname (ssget (cadr nent)) 0)))
    )
     
    Doug Broad, Jul 7, 2003
    #7
  8. That is just one of those "mean and lean" toolbox type thingies.
    Any other checking, IMO, should be done by the calling subr.
     
    Jason Piercey, Jul 7, 2003
    #8
  9. David Bethel

    Doug Broad Guest

    Very nice Herman. That would seem the simplest.
     
    Doug Broad, Jul 7, 2003
    #9
  10. David Bethel

    Jamie Duncan Guest

    memories..I have so few remaining


    --


    Jamie Duncan

    Consulting - If you're not part of the solution - there's money to be made
    in prolonging the problem.
     
    Jamie Duncan, Jul 8, 2003
    #10
  11. David Bethel

    Jamie Duncan Guest

    It is - and I got the same answer from anither news griuo - so easy if you
    look under blocks in the dxf section as opposed to attribs.

    Thanks Herman.


    --


    Jamie Duncan

    Consulting - If you're not part of the solution - there's money to be made
    in prolonging the problem.
     
    Jamie Duncan, Jul 8, 2003
    #11
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.