Try this credit to Kent Cooper for original code.
;; BlockSParts0Bylayer.lsp
;; = change all Parts of definitions of Selected Block(s) [other
;; than on Layer Defpoints] to Layer 0 with Color ByLayer
;; Kent Cooper, 3 November 2014
;; Modified by Alan h OCT 2020
;; now does linetype only
(vl-load-com)
(defun C:blocklt (/ nametolist blkss inc blk blknames ent edata obj)
(setq ltype (getstring "please enter linetype name"))
(if (tblsearch "Ltype" ltype)
(princ "Found")
(progn
(alert "Linetype not found please load linetype\n \nTry again")
(exit)
)
)
(defun nametolist (blk / blkobj blkname); get Block name and put it into list of names
(if (= (logand (cdr (assoc 70 (entget blk))) 4) 0) ; not an Xref
(progn
(setq
blkobj (vlax-ename->vla-object blk)
blkname
(vlax-get-property blkobj
(if (vlax-property-available-p blkobj 'EffectiveName) 'EffectiveName 'Name)
; to work with older versions that don't have dynamic Blocks
); ...get-property & blkname
); setq
(if
(not (member blkname blknames)); name not already in list
(setq blknames (append blknames (list blkname))); then -- add to end of list
); if
); progn
); if
); defun -- nametolist
(setq blkss (ssget '((0 . "INSERT")))); User selection of any number of Blocks/Minserts/Xrefs
(repeat (setq inc (sslength blkss)); get names from initial selection
(setq blk (ssname blkss (setq inc (1- inc))))
(nametolist blk)
); repeat
(while (setq blk (car blknames)); as long as there's another Block name in list
;; [done this way instead of via (repeat) or (foreach), so it can add nested Blocks' names to the list]
(setq ent (tblobjname "block" blk)); Block definition as entity
(while (setq ent (entnext ent)); then -- proceed through sub-entities in definition
(setq edata (entget ent))
(if (member '(0 . "INSERT") edata) (nametolist ent)); if nested Block, add name to end of list
(if (not (member '(8 . "Defpoints") edata)); process all entities NOT on Layer Defpoints
(progn
(setq obj (vlax-ename->vla-object ent))
(if (vlax-property-available-p obj 'Linetype)
(vla-put-linetype obj Ltype)
)
;(vla-put-color obj 256); color ByLayer
); progn
); if
); while -- sub-entities
(setq blknames (cdr blknames)); take first one off
); while
(command "_.regen")
(princ)
); defun