(Defun c:LMEL (/ _Explodable ssb i e ipt bnm )
(defun _Entnext ( e )
(if (setq e (entnext e)) (cons e (_Entnext e)))
)
(setvar 'cmdecho 0)
(defun _Explodable ( bn / bl Ent )
(cond
((null (setq bl (tblsearch "BLOCK" bn))))
((and (< (logior 2 (cdr(assoc 70 bl))) 3)
(setq Ent (entget (cdr (assoc -2 bl)))
Ent (entget (cdr (assoc 330 Ent))))
)
(entmod (subst (cons 280 1)
(assoc 280 Ent) Ent)))
)
)
(if (setq ssb (ssget "_X" '((-4 . "<OR") (-4 . "<AND")
(0 . "INSERT")(8 . "*S-Decking*") (-4 . "AND>")
(-4 . "<AND")
(0 . "MLINE") (8 . "TUBES") (-4 . "AND>")
(-4 . "OR>")))
)
(progn
(repeat (Setq i (sslength ssb))
(setq e (vlax-ename->vla-object (ssname ssb (Setq i (1- i))))
ln (Vla-get-layer e))
(cond
((eq (vla-get-objectname e) "AcDbBlockReference")
(if (not (member (setq bnm (vla-get-EffectiveName e)) blklst))
(progn
(_Explodable bnm)
(setq blklst (cons bnm blklst)))
)
(vlax-invoke e 'Move '(0.0 0.0 0.0)
(if (wcmatch (strcase ln) "*(SECONDARY)*")
'(0.0 200000.0 0.0) '(200000.0 0.0 0.0)))
(setq ang nil el (entlast) ssc (ssadd))
(Vlax-invoke e 'Explode)
(foreach itm (_Entnext el)
(Vla-put-layer (vlax-ename->vla-object itm) ln))
(Vla-delete e)
)
( T
(vlax-invoke e 'Move '(0.0 0.0 0.0) '(-200000.0 0.0 0.0))
(command-s "_Explode" (ssname ssb i) "")
)
)
)
(repeat 4
(vla-purgeall (vla-get-activedocument (vlax-get-acad-object)))
)
)
)
(princ)
)
Command: LMEL
@S_S_SS wrote:
NO sir
that's all that i need
i need to learn something from you how to select objects by layer
i mean that how to select objects in layer (tubes) as example
You need to use a filter like this, it selects objects under layer "TUBES" ( and its not case senstive ) on screen
(setq ss (ssget '((8 . "TUBES"))))
8 as DXF code for layer
You can limit the type of object by including DXF code 0 for Entity type
(setq ss (ssget '((0 . "MLINE") (8 . "TUBES"))))
The above line enables the user to select only "MLINE" under "TUBES" layer
HTH