Create a Template Module
Create a Template Module
To create a new Template Module, access the Advanced Settings overview page and select the Edit Template Modules option in the left menu.
The Manage Template Module page is displayed:
Click on the plus icon to create a Template Module:
The Create New Template side panel window is opened:
Fill in the following information:
- Template Type: Select the Template Type.
- You can choose to:
-
Add code before the template
-
Replace the template (default)
-
Add code after the related template
-
- You can choose to:
- Model Object Type: Template Model Object Type
- Select the Model Object Type for which the Template will be applied:
- Select the Model Object Type for which the Template will be applied:
- Part per Model Object Type: Depending on the selected Model Object Type, the list of its parts is displayed.
- Select the Part for which the Template will be applied as follows, with Hub selected as Model Object Type:
- Select the Part for which the Template will be applied as follows, with Hub selected as Model Object Type:
- Use for all future Model Objects: if you check the box, the Template will be automatically applied for all future Model Objects of the Type defined in Step 2
- Model Objects list: the list of Model Objects for the selected Model Object Type is displayed
- Select the Model Objects to which the Template will be applied, as shown in the example (with Hub selected as the Model Object Type)
- A search box allows you to filter the list of Model Objects.
- Select the Model Objects to which the Template will be applied, as shown in the example (with Hub selected as the Model Object Type)
- Editor: The Template code should be written in C# within the method WriteOutput(TargetObject targetObject, ITemplateContext templateContext)
- An IntelliSense editor (based on the Generator methods and classes) is available, for example:
- Some code snippets are available by typing bigenius:
- Select a snippet, such as
"iterator through terms"
, and the corresponding code will be inserted.
- Select a snippet, such as
- An IntelliSense editor (based on the Generator methods and classes) is available, for example:
- Click the API Documentation link to open the documentation and access guidance for developing a custom template.
- Click the Validate button to compile the Template code. Any compilation errors or warnings will be displayed below the code.
- Blecting the PREVIEW tab, you can preview the generation result of the Template Module
- By selecting the ARCHITECTURE MODEL VIEW tab, you can display the Architecture Model for a Model Object in a Template Module
A complete example of a Template Module can be found in the following article: Avoid to load all data in development.
Click on the SAVE button.
A notification confirms the correct creation:
Demonstration video