Custom tools

CADMATIC users often ask Cadmatic or a local distributor to provide tools that would perform specific actions in a specific user environment. If the requested functionality is not generally applicable to other customers, the tool is implemented as a custom script. The script can be either uncompiled source code (.mac) or a compiled binary script (.bs), and the implementation may also involve custom ribbons, panels, and icons that provide user interfaces for launching and using the tools.

Customer-specific script-based tools are not included in the normal CADMATIC product installer. Instead, a separate mechanism is used to manage their distribution and installation. The files are packaged into a compressed folder, and the package can be distributed to customers as soon as the tool is ready for use. The customer's CADMATIC administrator can then install the package using the CADMATIC desktop DM Tools utility.

In most cases, the delivery of custom tools is not dependent on the official software release cycle of main releases and updates. However, the binary script format often changes in major releases, and if custom tools have been delivered as binary scripts, the script vendor must recompile the script, update the installation package, and distribute the updated version. Another situation where users may be required to update their custom tools is when the custom tools themselves are modified or enhanced after their initial release.

Custom tools that Cadmatic provides under a maintenance agreement can be downloaded from the Cadmatic Customer Support Portal. If a custom tool should be available there but cannot be found, contact Cadmatic Customer Support for assistance.

Example custom tool

In this example, a custom tool can be launched from a button in the Tools tab of Plant Modeller. The tool opens a dialog that shows a menu, from which the user can select a meal to order.

We use 'ExaCustom' in the names of the files that are used to run the tool.

Our installation package is called ExaCustom.customization. The package consists of the following files:

customization.xml Installation configuration file that defines what will be installed and where. The name is always customization.xml.
ExaCustom.mac Custom tool script (a source code file).
ExaCustom.f Frame file used by the script.
ExaCustomRibbon.xml CustomUI object for launching the tool from the Plant Modeller ribbon.
ExaCustom.ico Icon to show in the ribbon.

Structure of installation configuration file

The installation configuration file, customization.xml, has the following structure:

Copy
<?xml version="1.0" encoding="UTF-8"?>
<custom_tool_installation name="Example Custom Tool" version="2.2">
    <customer name="Customer 1" />
    <customer name="Customer 2" />
    <cos_object database="LIBRARY" cos_object_type="Script Source">
        <attributes>
            .dD ExaCustom; .dG Example Custom Script; ...;;
        </attributes>
        <data import_file="ExaCustom.mac" />
    </cos_object>
    <cos_object database="LIBRARY" cos_object_type="Custom UI">
        ...
    </cos_object>
</custom_tool_installation>

The XML elements of the file are:

<?xml version="1.0" encoding="UTF-8"?>

This is the standard XML declaration that describes the XML version and character encoding used by the document.

<custom_tool_installation name=" " version=" ">

The custom_tool_installation element is the main element of the configuration file, and it encloses all other XML elements.

Element attributes:

  • name – Name of the tool.

  • version – Version number of the tool.

<customer name=" " />

The customer element identifies a user organization that is allowed to load and use the custom tool. Define each customer as a separate element.

Element attributes:

  • name – Name of the customer.

<cos_object database=" " cos_object_type=" ">

The cos_object element specifies the database used to store the COS object and the type of COS object to create.

Element attributes:

  • database – Target database. The value must be either 'LIBRARY' or 'PROJECT'.

  • cos_object_type – Type of COS object to create.

The cos_object element has attributes and data as sub-elements.

<attributes>

The attributes element specifies the COS attributes and attribute values to assign to the COS object. This is done using the normal tag record format used for assigning attributes to COS objects. The content is a semi-colon separated list where each attribute is represented by its identifying tag (abbreviation of three characters or fewer) followed by the attribute value.

<tag1> <value>; <tag2> <value>; … ;;

Important: Many custom tools access runtime-specific COS user attributes. The custom tool installer cannot create new COS attributes or verify whether a given attribute exists. Therefore, the tool vendor must provide clear instructions so that the administrator performing the installation can verify any required attributes before running the installer.

<data>

The data element specifies the data to import into the COS object.

Element attributes:

  • import_file – Name of the file (located at the root level of the installation package) from which to import the data.

Example installation package files

customization.xml

ExaCustom.mac

ExaCustom.f

ExaCustomRibbon.xml

ExaCustom.ico

Creating a custom tool installation package

The files required for installing and running the custom tool are packaged into a compressed archive (zip) that uses the .customization file extension. This package must contain:

  • All files required to run the tool: scripts, frame files, custom ribbons, and icons.

  • A configuration file that references the other files and defines how to install them. Typically, the library database is preferred because the tools are then available to all projects at all replicas.

For an example of the files to include in the package, see Example custom tool.

Do the following:

  1. Collect all files required to run the custom tool in the target environment.

    If a binary script is required, ensure that you have the compiled .bs file.

  2. Create the customization.xml configuration file to define how the tool will be installed.

    In this file, specify which data files to import into COS, their COS object types, and which COS attributes to assign. For details, see Structure of installation configuration file and the example configuration file customization.xml.

  3. Build the installation package.

    You can use a dedicated archiving program such as 7-Zip or WinZip for this.

    In this example, we use the built-in Microsoft Windows tools:

    1. Use the Windows Explorer function New > Compressed (zipped) Folder to create a new archive, and enter a suitable name.

    2. Copy or move the custom tool files and the installation configuration file into the package.

      Important: All installation files must reside at the root level of the package.

    3. Change the '.zip' file extension to '.customization', and confirm the change.

  4. The installation package is now ready. If special actions are required before or after installation, prepare a document that describes those actions for administrators.

  5. Deliver the .customization package and any additional instructions to the customer.

Installing custom tools

Install a custom tool from a .customization package. This creates a COS object of type 'Custom Tool Installation', as described in Tool installation, which is linked to all related COS objects.

Do the following:

  1. If additional instructions are provided, read them carefully.

  2. Open the CADMATIC desktop and select Object > Tools > Run DM Tools.

  3. Right-click the DM Tools dialog and select Install Custom Tool.

  4. Select the installation package from the file browser and click Open.

  5. When installation is complete, you are prompted to open the log file located at <project>/<workspace>/CustomToolInstalLog.txt. Click Yes to open the log file.

  6. Right-click the DM Tools dialog and select Exit.

  7. Open the target application and verify that the tool works as intended.

Updating custom tools

If you receive an update, install the new version in the same way as described in Installing custom tools. This updates the files in your environment.

Uninstalling custom tools

You can uninstall a custom tool by deleting its 'Custom Tool Installation' COS object. This removes all associated objects (scripts, frames, custom ribbons, icons).

Do the following:

  1. In the Project Environment dialog, browse to [project] or [library] > Resources > Tool Installation.

  2. Right-click the custom tool and select Delete.

Related topics

Tool installation