If I am correct in assuming that:
A) you want the Circles on their original Layers inside the Block definitions, but also want them to exist afterwards on the other Layer; and
B) you don't want the other parts to exist afterwards, since they will be removed in the process of the Block definition [when in a (command) function] and you haven't mentioned anything about keeping them; and
C) the answer to the BIG QUESTION in my previous Reply is Yes;
then try this [untested]:
(defun c:blk
(/ ss longitudinal circX transversal circY ent edata numberX numberY BlocknameX BlocknameY)
(setq
ss (ssget '((8 . "_EST-[2345]-arm_@@@_[XY],_EST-[2345]-arm_@@@_[XY]_rot,_EST-[2345]-arm_@@@_[XY]_dist,_EST-[2345]-arm_@@@_[XY]_linea"))))
;; overall single selection -- [2345] for any of those, @@@ for either "inf" or "sup", [XY] for either "X" or "Y"
longitudinal (ssadd); initially empty [also next 3 lines]
circX (ssadd)
transversal (ssadd)
circY (ssadd)
); setq
(repeat (setq n (sslength ss)); step through selection
(setq
ent (ssname ss (setq n (1- n)))
edata (entget ent); entity data list for type and Layer
); setq
(ssadd ent ; put into one of the selection sets
(if (wcmatch (cdr (assoc 8 edata)) "*X*")
longitudinal ; then
transversal ; else
); if
); ssadd
(if (member '(0 . "CIRCLE") edata)
(ssadd ent ; then -- also put into one of the Circle selection sets
(cond ;; [could be simplified to (if) if there would be no Circles on other Layer(s)]
((wcmatch (cdr (assoc 8 edata)) "*X_linea") circX)
((wcmatch (cdr (assoc 8 edata)) "*Y_linea") circY)
); cond
); ssadd
); if [no else -- do nothing if not a Circle]
); repeat
;BLOCK FOR REBARS IN X
(setq numberX 1); [slightly shortened way of determining Block name]
(while (tblsearch "BLOCK" (setq BlocknameX (strcat "ARM_LONG" (itoa numberX))))
(setq numberX (1+ numberX))
); while
(command
"_.Block" BlocknameX "0,0" longitudinal ""
"_.insert" BlocknameX "0,0" "" "" ""
"_.oops" ; bring back objects used for Block
); command
;BLOCK FOR REBARS IN Y
(setq numberY 1)
(while (tblsearch "BLOCK" (setq BlocknameY (strcat "ARM_TRANS" (itoa numberY))))
(setq numberY (1+ numberY))
); while
(command
"_.Block" BlocknameY "0,0" transversal ""
"_.insert" BlocknameY "0,0" "" "" ""
"_.oops" ; bring back objects used for Block
); command
;MOVE CIRCLES TO ANOTHER LAYER
(command
"_.chprop" circX circY "" "_layer" "_EST-ARM-REP" ""
;; can do both sets [remaining from OOPS commands above] together
"_.erase" longitudinal transversal "_remove" circX circY ""
;; remove all except Circles
); command
(princ)
); defun
[If my assumption B) above is incorrect, and you do want the other-than-Circle parts retained afterwards, omit the Erase command line entirely.]
Kent Cooper, AIA