Script Based Custom Tools

CADMATIC users often ask Cadmatic or a local distributor to provide tools that would perform some 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 uncompiled source code (.mac) or a compiled binary script (.bs), and the implementation may also involve custom ribbons, panels and icons that provide the user interfaces for launching and using the tools.

Customer-specific script-based tools are not included in the normal CADMATIC product installer. Instead, there is a separate mechanism for managing their distribution and installation. That is, 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. Then, the customer's CADMATIC administrator can install the package with CADMATIC desktop's 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. But, the binary script format does usually change 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 the users might be requested to update their custom tools is when the custom tools themselves are modified or enhanced after their initial release.

Custom tools that Cadmatic provides in the scope of a maintenance agreement can be downloaded from 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, we have a custom tool that can be launched from a button in the Tools tab of Plant Modeller. The tool opens a dialog that shows a menu and the user can select which meal to order from the list.

We use "ExaCustom" in the name of the files that are used for running 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 that the XML document uses.

<custom_tool_installation name=" " version=" ">

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

Element's 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's attributes:

  • name – Name of the customer.

<cos_object database=" " cos_object_type=" ">

The cos_object element specifies the database to use for storing the COS object and the type of the COS object to create.

Element's attributes:

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

  • cos_object_type – Type of the COS object to create.

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

<attributes>

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

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

Important: Many custom tools access run time specific COS user attributes. The custom tool installer cannot create new COS attributes or check whether a given COS attribute exists. Therefore, the vendor of the custom tool must provide adequate instructions, so that the administrator who will be doing the installation is aware of any attributes whose existence should be verified before running the installer.

<data>

The data element specifies the data to import as a dump to the COS object.

Element's attributes:

  • import_file – Name of the file (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 for installing and running the custom tool are packaged into a compressed archive folder (zip file) that has a .customization file extension. This distributable package must contain the following:

  • All the files that are needed for running the tool: scripts, frame files, custom ribbons, and icons.

  • A configuration file that references the other files and defines how to install them. Usually, the library database is the preferred installation location, because then the custom tools are accessible 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 the files that are needed for running the custom tool in the target environment.

    If a binary script is needed, make sure you have the compiled *.bs file.

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

    In this file you specify which data files to import to COS, what will be their COS object type, and what COS attributes to assign to them. 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 tools of Microsoft Windows.

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

    2. Copy or move the custom tool's files and the installation configuration file to the .zip package.

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

    3. Change the ".zip" file extension to ".customization". You are prompted to accept the change.

  4. The installation package is now ready. If any special actions will be needed, either before or after installing the tool, prepare a document that details those actions for the administrators who will be installing the tool.

  5. Deliver the .customization file and any special installation 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 the other COS objects of the custom tool.

Do the following:

  1. If the custom tool came with any additional installation instructions, read those carefully. There might be some tasks that you must do before running the installer or before the users start using the installed tool.

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

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

    A directory browser opens.

  4. Select the custom tool installation package and click Open.

  5. When the installation completes, you are prompted whether to open the installation log file that the installer stored in <project>/<workspace>/CustomToolInstalLog.txt. If you click Yes, the log opens in a text editor.

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

  7. Open the application where the tool was installed, and launch the tool to check that it works as intended.

Updating Custom Tools

If you receive an update for a custom tool, install the new version in the same way as you installed the previous version—as described in Installing Custom Tools. This will update the custom tool files in your environment.

Uninstalling Custom Tools

You can uninstall a custom tool by deleting its "Custom Tool Installation" COS object. This deletes all the referenced objects (scripts, frames, custom ribbons, icons) that are part of the same installation.

Do the following:

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

  2. Right-click the custom tool to be removed and select Delete.

Related Topics

Tool Installation