Reinaldo has 4 books and they are very good buy on Kindle very cheap and can copy code to notepad.
Re set visibilty I use Lee-mac's Dynamic block code, which includes using (LM:SetVisibilityState obj visibilty), you can look through the layouts and ssget "**U*" blocks which are dynamic blocks, you then check effective name matches yours, then use (LM:SetVisibilityState obj visibilty) the visibilty is read from the block you have picked.
The code you provided is almost there, it just needs rearranging, pick block get effective name and current visibilty, the do a ssget of the dynamic blocks and find the matching ones then update the visibity.
This is equal to like 15 lines of code. 4-15 There is no need to sort tab order as your changing any blocks you find.
Code:
(foreach layt (layoutlist)
Get a copy of Lee-mac dynamic block functions very useful. https://lee-mac.com/dynamicblockfunctions.html
You can have a look at this also.
Code:
(defun insdyne (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block "))))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v" lst))
(LM:SetVisibilityState obj ans)
(princ)
)
I saved Lee's functions into one file as above.