Add-ins are in-process COM or .NET clients implemented in their own DLL which is loaded into the Creo Elements/Direct Modeling process at runtime.
Since add-ins run in the process context of Creo Elements/Direct Modeling, they should use the same C and C++ run-time libraries as the main application for consistency. To assure this, your COM add-ins must be compiled with Visual Studio 2015.
Add-ins are platform-dependent, i.e. you must provide seperate 32-bit and 64-bit versions of your add-in. A 32-bit add-in cannot be loaded into a 64-bit process and vice versa.
32-bit add-ins should be compiled on a 32-bit machine to avoid problems. It is also possible to compile 32-bit add-ins on a 64 bit machine, but you have to take special care to:
64-bit add-ins must be compiled on a 64-bit machine. There is no supported way to cross-compile a 64-bit version of the add-in on a 32-bit machine. In addition, you have to make sure to:
CoCreate.OsdmServer.tlb
and CoCreate.OsdmObjects.tlb
Note: By default, Microsoft Visual Studio does not use the native 64-bit compilation tools, but uses the 32-bit tools in a cross-compilation mode. This default behaviour does not work properly for compiling 64-bit COM add-ins. This is a restriction in the Microsoft tools. In order to use the native 64-bit tools for compilation, you must start the special Visual Studio x64 Win64 Command prompt provided with the Visual Studio installation on 64-bit machines
Builds from the Visual Studio IDE are also affected by this problem. In order to
build 64-bit add-ins from the IDE, you must start it with
devenv /useenv
from the special 64-bit command prompt.
Deploying COM addins on a machine running Microsoft Windows Vista or Windows 7 requires special considerations. In general it's important to understand that in order for Creo Elements/Direct Modeling to find and use COM addins, they must be registered in the Windows registry. Before Vista, COM addins were written to register in the HKEY_LOCAL_MACHINE part of the registry, which required administrator privileges. As a fallback, Creo Elements/Direct Modeling would try to register the addin on the fly with restricted user privileges (by redirecting the registration to the HKEY_CURRENT_USER part of the registry). This is required for network deployment scenarios, where the addin will not be installed on a PC, but simply made available via a well-known network drive (see Locating addins above).
This redirection mechanism is no longer supported by Microsoft in Windows Vista. This means that the developer of a COM addin must decide at development time about the deployment strategy: Will the COM addin be deployed by an administrator on each local PC, or will the addin be registered by a standard user? If there is no requirement for administrative rights during addin deployment, we strongly suggest you write your COM addins so that they register themselves in the HKEY_CURRENT_USER portion of the registry. Otherwise addin deployment at customer sites will fail to support network deployment scenarios.
If the COM addin registration requires administrative rights, you must make sure it is installed by an administrator at the customer site. In particular, this can be required if your addin is not a standalone addin, but needs to be installed as part of another application that wants to integrate with Creo Elements/Direct Modeling. The COM add-in wizard provides options for both deployment strategies.
.NET add-ins must be compiled with Visual Studio 2015, using the .NET frameworks 4.0.
Project references must be set to the CoCreate.OsdmServer.dll
and CoCreate.OsdmObjects.dll
object model assemblies.
During startup, Creo Elements/Direct Modeling will search several directories for installed add-ins, and will attempt to load any add-ins it finds there. The search order is as follows:
personality/<LANG>/sd_customize/
directory in the Creo Elements/Direct Modeling installation directorypersonality
directorySearching the directories in this order allows control over which add-ins are made available globally within the company, at a particular site, or for individual users. The Customization Concepts Guide in the online help documentation for Creo Elements/Direct Modeling explains how those directories can be configured.
In each of these directories, Creo Elements/Direct Modeling will try to locate a folder called
Addins
. Add-ins must be installed to this folder. Here is a simple
example:
| |-- Addins | |------ TestAddin | |------- TestAddin.cfg |------- TestAddin.dll
Creo Elements/Direct Modeling assumes that a subdirectory TestAddin
will contain a
configuration file called TestAddin.cfg
which provides detailed
information about the add-in. Most add-ins will be compiled into a single DLL as
shown above. While it is convenient to install the add-in DLL at the same location as
the associated configuration file, this is not a strict requirement for COM add-ins,
and other installation options are available.
The add-in configuration file describes, in XML format, add-in attributes such as
its name, description, and ID. They are generated by the add-in wizard and typically you only
need to adjust the ModuleName
and Description
tags.
A sample COM add-in configuration file:
<?xml version="1.0" encoding="utf-8" ?> <AddinConfig> <ProgID>TestAddin </ProgID> <VersionProgID> </VersionProgID> <ModuleName>My first test add-in </ModuleName> <Description> </Description> <CommandLineSafe>false </CommandLineSafe> </AddinConfig>
A sample .NET add-in configuration file:
<?xml version="1.0" encoding="utf-8" ?> <AddinConfig> <AssemblyFile>TestAddin.dll </AssemblyFile> <AddinClass> MyCompanyName.TestAddin </AddinClass> <AlternativeUniqueName> MyCompanyName.TestAddin </AlternativeUniqueName> <UseDefaultAppDomain> true </UseDefaultAppDomain> <ModuleName>My first .NET add-in </ModuleName> <Description> </Description> <CommandLineSafe>false </CommandLineSafe> </AddinConfig>
Ignoring the XML boilerplate, this is what the individual tags mean:
ProgID
is the human-readable version of the GUID. While not guaranteed
to be unique, it is usually preferred over specifying the GUID. Each COM server has
its own ProgID and can be located using this ID. Add-ins are, in fact,
both COM clients and COM servers, since they also implement several interfaces (see
below), which is why the add-in also needs to
have its own ProgID
.Application/Modules/Add-Ins
dialog).false
if your add-in displays UI while its
code is executed.The parameters Description
and CommandLineSafe
are
currently not implemented.
In the XML example above, the name of the file which contains the actual add-in code is not explicitly specified. To find and load the add-in code, Creo Elements/Direct Modeling proceeds as follows:
ProgID
in the registry, it will
search for a DLL in the add-in directory which has the same basename as the
configuration file; in our example, that would be TestAddin.dll
. If
it finds this file, it will try to register it with COM by running
regsvr32
on it. On Vista, the success of this registration attempt depends on the elevation
state of the application, and the kind of registration code in the add-in.
If the add-in registers into the HKCR and HKLM branches of the registry,
on-the-fly registration will only work if the application runs elevated.
If the registration code writes to HKCU, on-the-fly registration will only
work if the application is not elevated.ProgID
is now found in the registry, Creo Elements/Direct Modeling will use the standard
COM mechanism (i.e. CoCreateInstance
) to load the add-in code.The recommended way to install a COM add-in is as follows:
regsvr32
.If you know that end users will always have sufficient privileges to write to the registry, you can also skip the last registration step and have Creo Elements/Direct Modeling perform it for you.
See the notes on COM add-in installation. Differences:
regasm
must be used.
This is the preferred approach, particularly on Vista or Windows 7 where Creo Elements/Direct Modeling will usually
run non-elevated and will therefore not be able to perform on-the-fly registration.When Creo Elements/Direct Modeling activates an add-in, it checks whether an associated Lisp file was deployed in the same directory where the configuration file was found. For example, if the configuration file is called TestAddin.cfg, and the same directory contains a file TestAddin.lsp, that Lisp file will be loaded. This can be used to integrate add-in functionality with the customization capabilities provided in the Developer's Kit; for example, user interface elements can be defined in Lisp which control the user interaction and then execute functionality in the add-in upon user request. See Integrating add-ins and Lisp for more details.
For use with the COM/.NET API, we provide an add-in wizard which can be installed in Visual Studio. Running the add-in wizard within Visual Studio will automatically produce an add-in client with the following features:
Wizards are currently available for C++ COM and C# add-ins. See The Creo Elements/Direct Modeling Add-in wizard for details on installation and usage.
Creo Elements/Direct Modeling assumes that the add-in implements certain standard interfaces through which it can communicate with the add-in. Creo Elements/Direct Modeling will query the add-in for those interfaces and call them as appropriate.
The files OsdmServer.tlb
and CoCreate.OsdmServer.dll
contain the
required add-in interface definitions for COM and .NET clients, respectively.
This interface contains functions that control the lifecycle of an add-in. The most important member functions are:
Add-ins can register one or several commands with the application. Typically, each such command is represented in the UI by a button in the add-in's own menu. IOsdmCommandTarget provides member functions to control user interaction:
This interface is optional. If the add-in implements a default dispatch interface, methods in this interface can be called via the invoke-addin Lisp command. This provides a (preferred) alternative to the IOsdmCommandTarget.Execute interface. For details, see the section on Lisp interoperability.
This interface is optional. Its purpose is to integrate unit tests in the add-in into Creo Elements/Direct Modeling's unit test infrastructure.
Count
- 1.Add-ins generated by the add-in wizard optionally also implement the test interfaces. To run the tests for an add-in from within Creo Elements/Direct Modeling, proceed as follows:
Step 1: Start Creo Elements/Direct Modeling. Check the Applications/Modules/Add-Ins
dialog to
see whether the add-ins you want to test have been detected during startup.
Step 2: Using the dialog, activate the add-ins which you want to test.
Step 3: Open the console window (View/Console
).
Test results and messages will appear in this window when you run tests.
Step 4: To run test 0 from the set of tests implemented in the add-in, enter the following Lisp command in the user command line:
(f2::run-addin-test "yourprogid" 0)
"yourprogid" is the ProgID
of the add-in you want to test (see also
the section on add-in configuration files) The result of the tests are displayed in
the console window.
Set-up and tear-down functions can be called as follows:
(f2::setup-addin-tests "yourprogid") ;; execute any number of tests now using f2::run-addin-test (f2::teardown-addin-tests "yourprogid")
For development partners, we are preparing more convenient ways to run unit tests in add-ins (using a so-called "unit test browser").
External COM clients can be either vtable ("raw COM") clients or dispatch clients. If you are not familiar with these terms: They mean that it is possible to use both strictly-typed languages such as C or C++ and loosely-typed languages such as VBscript to interface to Creo Elements/Direct Modeling.
To build 64-bit external COM clients, it is important to use the right development environment. For details, please refer to the notes above on building 64-bit COM addins.
External .NET clients are currently not supported.
Add-ins run in the main thread of the Creo Elements/Direct Modeling process, so there is no interprocess communication and only low parameter marshaling overhead. Therefore, add-ins should be used for all integration tasks which require frequent calls into the Creo Elements/Direct Modeling object model.
Typical add-in design models:
Add-ins are loaded and activated by an instance of Creo Elements/Direct Modeling which is typically started by and end user, so they often provide a Modeling-compliant user interface through which users can interact with the add-in's functionality.
External clients typically instantiate Creo Elements/Direct Modeling in the background and drive this instance with their requests; there is usually no user interaction within Creo Elements/Direct Modeling. In scenarios where performance is less important than flexibility and independence from Creo Elements/Direct Modeling, external clients can be a better choice. External clients are best used in scenarios where the time to instantiate the server and to communicate with the server is significantly lower than the actual computational task at hand.