Thanks for posting the solutions you found. I actually misread your OP. I thought you wanted to change the Attribute to include both the Layout name & Drawing name.
I would still recommend for DNO.lsp to change the Attribute using a FIELD this way when the Drawing name changes like if you do a SaveAs the Attribute value automatically updates:
; dno updates block attribute value to dwgname
; OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script/m-p/12421113#M458538
(defun c:dno (/ bname tag)
(vl-load-com)
(setq bname "TitleBlockInformation")
(setq tag "DWGNAME")
(vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for a b
(and (vlax-property-available-p a 'name)
(= (strcase bname) (strcase (vla-get-name a)))
(vl-some '(lambda (x)
(and (= (strcase tag) (strcase (vla-get-tagstring x)))
(vla-put-textstring x "%<\\AcVar Filename \\f \"%fn2\">%") ; put dwgname as field
; (vla-put-textstring x (vl-filename-base (getvar 'dwgname)))
)
)
(vlax-invoke a 'getattributes)
)
)
)
)
(vla-Regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport) ; regen vport to refresh field
(princ)
)
As for the Layout name, I'm not sure why you need that to match with the Attribute value when in reality all you need is to change it to match with the Drawing name which is what you really want. This can be done using this simple line of code:
(if(/=(getvar"ctab")"Model")(vl-cmdf"_.Layout""_R"(getvar"ctab")(vl-filename-base (getvar 'dwgname))))
Lastly, I'm also not sure why you want the Layout name to match with the Drawing name. Whenever you PLOT or PUBLISH, the Drawing name is already placed as the prefix followed by the Layout name. If you rename the Layout to always match with the Drawing name then the plotted file name would show the same name twice.