Pragmatically create a union all command

Hi

I am looking to create a programmatically a model which union all’s the models in a sub-portfolio. The idea is to create one larger view with all the sub models.

Do you know if this is possible?