Action via code

Is it possible assign an action to button via code?
Alternatively is it possible open and edit the model file of a toolbar?
Thank you.

What do you mean “via code”? Do you mean at runtime?

Sure, model files are just Zip archives. You can use 7-Zip and modify the Actions.xml file

Yes, at runtime.
Thank you.

You can assign different code at runtime thanks to HEScript.:

Is it possible create at runtime a button or a menu item?

Yes, but it’s complex. It would be better to create buttons and menu items at design time, make them invisible and change their properties/make them visible at runtime.