That's what I needed CAB. After some experimenting this is what I came up with:
;;;------------------------------------------------------------------------------------------------
;;;Thanks to J. Roper for this section:
;;---------------------------------------------------------
;ATT:GETS - Utility routine to get all attributes for
;an insert object (EN).
;;
;;You pass this function an entity name, like something that would be returned from this example:
;;(setq EN (car (entsel "\nSelect block")))
;;an entity name looks like this when returned on a command line --><Entity name: 4119ab90>
;;You use this function like this: (setq ATTLIST (ATT:GETS EN))
;;it returns a list like this ---> (("TAG1 . "VALUE1")("TAG2" . "VALUE2")....)
(defun ATT:GETS (EN / EL RES)
;entnext goes on to the next entity. If what you passed is an attributed block, the next entity will be an attribute.
(setq EN (entnext EN)
EL (entget EN));entget "breaks open" the entity name to reveal the entity list
(while (= "ATTRIB" (cdr (assoc 0 EL)));we check the entity list to see if it is an attribute
(setq RES (cons
(cons (cdr (assoc 2 EL));if it is, we create a list of its tag and value, dxf code 2 and 1, using CONS
(cdr (assoc 1 EL))) RES)
EN (entnext EN);go to the next entity
EL (entget EN)));get the next entities list
(reverse RES);reverse the list to put it in proper order.
)
(defun _listofblockswithnestedblock ( nested / lst name )
(vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)));for each block in drawing do the code
(if;if block is in layout, is xref and if is anonymous, skip to next block
(and
(= :vlax-false (vla-get-islayout block))
(= :vlax-false (vla-get-isxref block))
(not (wcmatch (setq name (vla-get-name block)) "`**"))
)
(vlax-for obj block;for all other blocks, do code
(if
(and
(= "AcDbBlockReference" (vla-get-objectname obj))
(or
(and
(vlax-property-available-p obj 'effectivename)
(= (strcase nested) (strcase (vla-get-effectivename obj)))
);and
(= (strcase nested) (strcase (vla-get-name obj)))
);or
(not (member name lst))
);and
;;; (setq lst (cons name lst))
;;; (setq lst (cons (vlax-vla-object->ename obj) lst))
;;; (setq lst (cons (ATT:GETS (vlax-vla-object->ename obj)) lst))
;;; (setq lst (cons (car (ATT:GETS (vlax-vla-object->ename obj))) lst))
(setq lst (cons (cdar (ATT:GETS (vlax-vla-object->ename obj))) lst)) ;;;ATT:GETS is a sub-routine I use to get attribute info.
;;;(setq lst (cons (cdar (ATT:GETS (car (entsel)))) lst))
);if
);vlax-for
);if
);vlax-for
lst
);defun
(defun LM:ss->ent ( ss / i l )
;;; (if ss (repeat (setq i (sslength ss)) (setq l (cons (cdr (assoc 2 (entget (ssname ss (setq i (1- i)))))) l))))
(if ss (repeat (setq i (sslength ss)) (setq l (cons (cdar (ATT:GETS (ssname ss (setq i (1- i))))) l))))
);defun
;;;USE
(setq Allblocks (_listofblockswithnestedblock "EQPMTAG"))
(setq Allblocks (append (LM:ss->ent (ssget "_X" '((2 . "EQPMTAG")))) Allblocks))
It will return a list of all the tags' numbers as strings in a list. I know there's probably a more elegant way of doing this, but it works for me.
PS, I'll be sure to give credit in the code when I'm done. Thanks for the help guys. This has been a great learning experience. I'm sure I'll be asking more later.
Rabbit