Yes - I was thinking MLEADER instead of LEADER. Didn't realize Steven P was talking about the old style Leaders. The old leaders were "governed" by dim variables.
Hello everyone.
I don't want to take sides. But I think Mr. GLVCVS is right. In my office, we've sometimes had to work with closed polylines inside other closed polylines. This is a possibility that needs to be taken into account in some cases.
Although I don't know if it's necessary in this case.
You could try this too:
(defun c:foo (/ a d)
(vlax-for l (vla-get-layers (setq d (vla-get-activedocument (vlax-get-acad-object))))
(cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
)
(vlax-for b (vla-get-blocks d)
(if (= 0 (vlax-get b 'isxref) (vlax-get b 'islayout))
(vlax-for o b
(vl-catch-all-apply 'vla-put-layer (list o "0"))
(vl-catch-all-apply 'vla-put-color (list o 256))
)
)
)
(foreach l a (vlax-put l 'lock -1))
(vla-purgeall d)
(vla-regen d acactiveviewport)
(princ)
)
I am thinking you might use this from Lee Mac to get a list of nested blocks and work from there:
https://lee-mac.com/extractnestedblock.html
I think this is the related part of the code
;;https://lee-mac.com/extractnestedblock.html
;;USe this line to select a block
(enb:getreferences (cdr (assoc 2 (entget (car(entsel))))))
; Use this to loop through the blocks, in this case it is making a list, in your case (ssget "_X") and modify assoc codes to by block / layer colouras and layer codes.
(defun enb:getreferences ( blk / ent enx lst )
(if (setq ent (tblobjname "block" blk))
(foreach dxf (entget (cdr (assoc 330 (entget ent))))
(if
(and
(= 331 (car dxf))
(setq ent (cdr dxf))
(setq enx (entget ent))
(setq enx (entget (cdr (assoc 330 (reverse enx)))))
)
(if (wcmatch (strcase (setq blk (cdr (assoc 2 enx)))) "`**_SPACE")
(setq lst (cons (list ent) lst))
(setq lst (append (mapcar '(lambda ( l ) (cons ent l)) (enb:getreferences blk)) lst)) ;; Change this line to set colours / layers
)
)
)
)
lst
)
That might give you a start if you want to do some thinking