When operating on objects nested within block definitions in addition to primary objects, it typically becomes easier to iterate over the ActiveX Block Collection, e.g.:
(defun c:fixlay ( / doc lay lst ltp lyr )
(setq lst
'(
"DASHED"
"CENTER"
"PHANTOM"
)
)
(setq doc (vla-get-activedocument (vlax-get-acad-object))
lyr (vla-get-layers doc)
)
(vlax-for blk (vla-get-blocks doc)
(if (= :vlax-false (vla-get-isxref blk))
(vlax-for obj blk
(if (and (member (setq ltp (strcase (vla-get-linetype obj))) lst)
(vlax-write-enabled-p obj)
(or (member ltp lay)
(and (vla-add lyr ltp)
(setq lay (cons ltp lay))
)
)
)
(progn
(vla-put-linetype obj "bylayer")
(vla-put-linetypescale obj 0.2)
(vla-put-layer obj ltp)
)
)
)
)
)
(princ)
)
(vl-load-com) (princ)