Is that possible to generate a template for vardefs?

Hi all,

What I am trying to do here is, when you have a configuration panel and there you have a list of modules that you want to relate to a custom module?

That will include subpanels , relatioships, fields etc on the selected module. I know is possible to do it on Studio but via code, what are the methods that I need to use.