Skip to content

Scripting Example 1: Creating a New Model

This sample script is designed to demonstrate how a new model can be created from the scratch using raw model creation APIs. These APIs are designed to enable users to populate a new model through scripting. The supported use cases include creating a CIM model from various data sources.

Hands-on

Invoked ‘Run Python→ via Config’ from the global context menu, which can be initiated by right-mouse-clicking a bank spot in the tree Panel. A popup wizard window will appear. Select the script function configuration titled “Create New Model” from the popup dropdown list

Scripting Example 1: Creating a New Model – figure 1

If the popup window is not displayed, that means you don’t have the pre-defined script functions in your configuration. Alternatively, you can run the same script from the file directly, as illustrated below

Scripting Example 1: Creating a New Model – figure 2

If the execution is successful, you will get the following prompt,

Scripting Example 1: Creating a New Model – figure 3

After clicking the ‘OK’ button, you will find the newly-created model has been loaded into the Tool.

Scripting Example 1: Creating a New Model – figure 4

Code Analysis

The executed script, located under folder \CIMSpy\scripting, is explained below.

Scripting Example 1: Creating a New Model – figure 5

Note

The raw model creation APIs are designed for high-performance. These APIs simply populate the object models and then rely on a post-process to index the populated objects and make the populated model ready for use. Check the Model APIs for more details.