I have a model with multiple instances of a variant subsystem. The variant subsystem itself is in a library. How can I choose which variant to use for each instance using a script? Currently I use the PostLoadFcn callback of my top model to set active variant of each instance using set_param(). But if I edit the variant library block (and I do this often), all instances go back to the default variant in my top model. So I need a way to change them back before I run a simulation, and I don't want to have to close and re-open the top model just to do this (invoking the PostLoadFcn callback).
If I use the InitFcn to set the active variant, I get an error that I can't change variant during simulation.