That's the code! Now:
Go in and edit all your styles to use layers: you can use materials to make global changes easier, but have all the display properties tied to a specific layer. An examle would be if you want to control the hatch of a wall put it on layer "A-Wall-Patt" and make all properties "bylayer". In a file save all the different layer states for all the different plan conditions you use: I have 'Floor Plan', 'Reflected Plan', 'Screened', 'Reflected Screened', and 'Standard'. Now you can have more, for different detail etc, but this is all I need. I use the Layer Standard File to save my layer states - that way it's easy to find them via code (I'll include that code at the end of this post).
Now the easiest way to implement this would be to set up a pull down, or series of toolbar buttons, or even a tool palette. Use the following in a macro:
(jb:LayerStateEngine lstatename dwgname layerlist)
'lstatename As String: the name of the layer state to run: "Floor Plan"
'Dwgname As String: the name and path of the drawing with the saved layer states.
'layerlist As List: a list of the layers to change
OK, the LayerList.
(jb:GetLayerList "X_Base")
returns all the layers associated with the xref "X_Base" ala "X_Base|A-Wall"
(jb:GetLayerList "*")
returns all layer names xref and local
(jb:GetLayerList nil)
returns only local layer names - no xrefs
So as you can see with this code you have complete control over xrefs and the display of their layers.