replace (entsel) with....

Discussion in 'AutoCAD' started by jclaidler, May 19, 2004.

  1. jclaidler

    jclaidler Guest

    The below code searches for a titleblock, saves attribute values then deletes it. After inserting a new titleblock, the attribute values saved are applied to the new tb. The question is, how can I replace the (entsel) with the 'selection set' titleblock ??

    (setq result nil)
    (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (setq result (cons (vla-get-name block) result ) ))

    (foreach name (reverse result)

    (if (setq ss (ssget "X" (list '(0 . "INSERT")(cons 2 name)(cons 66 1))))

    (if (not (or (or
    (findfile (strcat "N:/AutoCAD Support Files/Acco Standard Files/Standard Symbols/Symbols/" name ".dwg"))
    (findfile (strcat "N:/AutoCAD Support Files/" name ".dwg"))
    (findfile (strcat "N:/AutoCAD Support Files/Acco Standard Files/Standard Title Blocks/" name ".dwg"))
    ))
    )


    (progn

    (defun get-att-val (TagNme / CurEnt CurObj RetVal)

    (vl-load-com)

    (if (setq CurEnt (car (entsel))) ; <--- replace this
    (progn
    (setq CurObj (vlax-ename->vla-object CurEnt))
    (if (and
    (eq (vla-get-ObjectName CurObj) "AcDbBlockReference")
    (vla-get-HasAttributes CurObj)
    )
    (mapcar '(lambda (Att)(if (eq TagNme (vla-get-TagString Att))(setq RetVal (vla-get-TextString Att))))
    (vlax-invoke CurObj "GetAttributes"))
    )
    )
    )

    RetVal
    )

    (setq designation1 (get-att-val "DESCRIPTION_ONE"))
    (setq designation2 (get-att-val "DESCRIPTION_TWO"))
    (setq designation3 (get-att-val "DESCRIPTION_THREE"))

    (repeat (setq i (sslength ss))(vl-catch-all-apply 'vla-delete (list (vlax-ename->vla-object (ssname ss (setq i (1- i)))))))

    )


    )
    )
    )
     
    jclaidler, May 19, 2004
    #1
  2. jclaidler

    ECCAD Guest

    (if (setq CurEnt (car (entsel))) ; <--- replace this
    (progn
    -----------
    (setq CurEnt ss); make a copy of ss
    (if CurEnt
    (progn

    Bob
     
    ECCAD, May 19, 2004
    #2
  3. jclaidler

    jclaidler Guest

    I've tried that, it doesn't work.
     
    jclaidler, May 19, 2004
    #3
  4. jclaidler

    JRWalker Guest

    Entsel only returns an entity. Selection sets are groups of entities (even
    only if there is one item in the selection set). You will either have to get
    the first entity or cycle through the selection set to process all entities.

    JRWalker
     
    JRWalker, May 19, 2004
    #4
  5. jclaidler

    ECCAD Guest

    (setq CurEnt (ssname ss 0)); Get the entity name.
    ??

    Bob
     
    ECCAD, May 19, 2004
    #5
  6. jclaidler

    jclaidler Guest

    that did it.. thanks
     
    jclaidler, May 19, 2004
    #6
  7. jclaidler

    ECCAD Guest

    Ok,
    Thanks.
    Bob
     
    ECCAD, May 19, 2004
    #7
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.