C# API Examples
To help you get started, your UModel package contains an example C# project, which is located at C:\Users\<username>\Documents\Altova\UModel2023\UModelExamples\API.
Importantly, this example project includes a reference to the UModel Type Library, see How to Reference the UModel Type Library. A reference to the UModel Type Library is required in each project where you need the UModel API. This makes it possible to instantiate the main application object from your code as follows:
UModelLib.Application um = new UModelLib.Application();
If you have a 64-bit operating system and are using a 32-bit installation of UModel, add the x86 platform in the solution's Configuration Manager and build the sample using this configuration. To access Configuration Manager, run the menu command Build | Configuration Manager.
The example application displays a Windows form with buttons that invoke basic UModel operations:
•Open All Diagrams
•Generate documentation for the currently active document
•Shows how to listen to UModel events (OnDocumentOpened Event On/Off)
The code essentially consists of a series of handlers for the buttons in the user interface shown above. Note that you may need to adjust the path to the UModel examples folder which is referenced from the code.