Using the code generator - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

Start the code generator, and you will find your new interfaces listed under the Not Used node in the tree view. This means the code generator does not see them as part of any project yet. If you try to generate code at this point, references within the code to existing SPF classes/interfaces may be missing (for example, Inherits relationships, method stubs), as project referencing has not been applied during generation.

You will see that there is a node for your new custom project. To correctly generate code for the new interfaces, you must move ALL newly defined interfaces to this node in code generator before generating any code. To do this, right-click each of your new interfaces and select Move To, then click the module you want to move each to, such as MyCustomModule. If you move only one interface at a time and try to generate code for it, any references to the other new interfaces within the code will be missing. This is because interfaces under the Not Used node are not known to the other projects.

To view the generated code, expand each interface and select one of the files.

To generate source files, right-click the interface, and select either Generate Base File or Generate Default File. To generate all source files at once, right-click the project node instead. The generated VB files will be saved in the application directory.

When you start the code generator, it will list all the modules that are in the settings.xml file and under each module will be the list of interfaces inside that module.

Next time you open the code generator, if you add the generated and default interface file into your custom assembly, you will find your InterfaceDef(s) underneath the module.

Expand the node for your custom InterfaceDef, and you will see the two VB files that will be produced from this interface. If you click on one of the files in the tree view, the code will be displayed in the right pane.

Right-click the InterfaceDef, and choose Generate base file and then do the same for Generate default file.

Now, open Windows Explorer and navigate to the SPF Code Generator folder. You should find a folder structure similar to the following:

This is the folder structure used by the SmartPlant Foundation Development group. It is not necessary that you organize your source in this way. You can use as much of this structure or as little as you want. For example, let's say that you want to organize these files under Project > Schema > Interface > and so on. You would copy the structure from Schema on down into your project folder.

In the Solution Explorer within Visual Studio, click the Show All Files toolbar button. You will now see the new source files representing the interface. Right-click each file, and select Include in project.

The files are now part of your project and will be visible under the training assembly or your custom assembly next time you open the code generator.