Implementing a custom template

In this example custom template implementation, we will walk you through the process of creating a custom structural unit template called 'MyLadder', a simple vertical ladder without mounting legs.

This implementation provides two interface definitions, meaning that project administrators can create new Construction Settings objects from two types of templates. Selecting a template opens the Structural Unit Templates editor where administrator can define the static parameters of the structural unit to create.

When inserting a ladder into the 3D model, designers are prompted to define these run-time parameters:

  • Point 1 – the center point of the bottom of the ladder
  • Point 2 – the top height of the ladder (z-maximum)
  • Direction – the facing direction of the ladder (rotation around its local z-axis)

The main steps of the custom template creation process are described in the following sections:

  1. Creating the interface definitions

  2. Creating the builder script

  3. Creating the bitmap images

  4. Testing the custom template

Creating the interface definitions

The creation of a custom structural unit template starts from creating the interface definitions and saving them in the project database.

An interface definition is a list of standard CADMATIC style tag records where each tag record defines one interface. The tags that can be used are described below.

In this example, we create two interface definitions. 'MyLadder_01' allows creating ladders where rungs and stringers use a different profile, and there are also extra materials (bolts, nuts, washers). 'MyLadder_02' uses the same profile for the whole construction and has no extra materials.

Do the following:

  1. In the Project Environment dialog, browse to [project] > Resources > User Data.

  2. If the 'SuInterfaceIndexExt' configuration object does not exist, select New > User Data to create it. When creating the object, set the 'User Data for application' attribute to 'pm'.

  3. Open the 'SuInterfaceIndexExt' configuration object for editing, and copy the following interface definitions into the editor.

  4. Click OK to close the editor.

Result

Creating the builder script

Developing the builder script is the major part of creating a custom structural unit template. The script implements functions that the Structural Unit Designer kernel calls back when the user does one of the following:

  • Creates or edits a Construction Settings object for a structural unit.
  • Inserts a structural unit into the 3D model.

The script call-back function names are fixed, based on the value of the 'ifc' tag in the interface definition. Here we assume that this value is 'MyLadder_01'.

The complete builder script that we use in this example is available in 'MyLadder' script. We strongly recommend that you examine how the script works, but below you can find descriptions of the mandatory function interfaces used in the script.

Script call-backs for managing construction settings

Script call-backs for creating the structural unit 3D model

Storing the builder script in the project

Add the completed template script to the project database.

Do the following:

  1. In the Project Environment dialog, browse to Resources > Scripts.

  2. Select New > Script Source, specify the object attributes, and click OK.

    Note: The script name is 'MyLadder'. Do not add a .mac extension to the name.

  3. Open the 'MyLadder' script object for editing, and copy the script code from 'MyLadder' script into the script editor.

  4. Save and check in the script.

Result

Creating the bitmap images

When creating a new custom structural unit template, you need a number of bitmap images that will be displayed in the user interface to indicate the type of the structural unit and its parameters. The names of the bitmap images must match exactly the names used in the interface definition.

Example Images

In this example, we use four bitmap images for each ladder type (interface definition): icon graphic, thumbnail image, preview image, and image with parameter indicators. You can copy the example images from the table below.

Storing the bitmap images in the project

Add the bitmap images of the structural unit to the project database.

Prerequisites

  • Your computer is configured to associate the .bmp file name extension with an application that allows editing bitmap images and not just viewing them.

Do the following:

  1. In the Project Environment dialog, browse to Resources > Icons.

  2. Add each required bitmap as follows:

    1. Select New > Icon, set icon type to '.bmp', and click OK.

    2. In the Edit Object Attributes dialog, enter the bitmap name, set 'Icon for application' to 'pm', and click OK.

      The bitmap name must match the name specified in the interface definition, including exact capitalization of letters.

    3. Double-click the bitmap to open it in the graphics program associated with the .bmp file name extension.

    4. Copy the appropriate image into the graphics program.

    5. Save and close the image.

  3. Check in the bitmap objects.

Result

Testing the custom template

When the required resources of a custom template are defined, test that you can use the custom template to define a new structural unit configuration and insert it into the 3D model.

Do the following:

  1. As an administrator, create a new Construction Settings object.

    1. In the Project Environment dialog, browse to [project] > Specifications > Construction > Structural Units.

    2. Select New > Construction Settings.

      The Select Structural Unit Template dialog opens listing the existing templates.

    3. Select one of the ladder types defined in the interface definition, and click OK.

      The Structural Unit Templates dialog opens displaying the parameters of the structural unit.

    4. Specify the parameter values, and click OK. It is now possible to insert structural units of this type into the 3D model.

  2. As a designer, insert a new structural unit into the model.

    1. On the Structural tab of Plant Modeller, in the Structural Unit group, select Insert.

    2. In the object browser, select the custom ladder from the list and click OK.

    3. Select 'Point 1' from the 3D model. This is the center point of the bottom of the ladder.

    4. Select 'Point 2' from the 3D model. This is the z-maximum of the upper part of the ladder.

    5. Define the facing direction of the ladder in the 3D model.

    6. Enter a name for the structural unit and click OK.

      The ladder is inserted in the specified location.

  3. As a designer, check that you can manage the new structural unit and its extra materials.

    1. On the Structural tab of Plant Modeller, in the Structural Unit group, select Manage.

      The Structural Units dialog opens listing the structural units of the model.

    2. Select the new structural unit from the list, and then click Extra Materials.

      The Manage Extra Materials dialog opens listing the extra materials defined in the template configuration.

    3. You can select an extra material and then click Update to edit its quantity or Unassign to delete it. You can add new materials by clicking Assign.

    4. Close the extra material and structural unit management tools.

Result

The custom structural unit template is ready to be used in the project.

You can use CX export and import to copy templates between projects.