VSTA Macro Concepts

This section provides background information about Visual Studio Tools for Applications (VSTA) macros.

This page discusses:

Overview

This section contains an overview.

Microsoft Visual Studio Tools for Applications (VSTA) is integrated within the 3DEXPERIENCE platform. If you were accustomed to writing VBA macros in earlier releases, you can migrate to this new technology to benefit from new .NET languages for writing scripts.

The existing macros UI has been enhanced with a new sort of macro library, called a PLM VSTA project. As for PLM Directories and PLM VBA Projects, you can also create, add or remove PLM VSTA Projects. A PLM VSTA project is mainly defined by its name and its language (VB.NET or C#).

A VSTA project, when opened, will be built and introspected so that its macros (i.e. public shared subs in VB.NET or public static void functions in C#, whose name starts with "Macro") are displayed. You can then run a macro, edit, rename or delete a macro in Visual Studio. These actions are basically the same as for the other existing types of macros libraries, except for the release/debug mode concept.

When you edit the VSTA project within Visual Studio, the whole 3DEXPERIENCE platform object model is accessible via VSTA's IntelliSense. This technology allows auto-completion while typing.

Performance, Capacity and Scalability

This section discusses performance, capacity and scalability.

The VSTA 2017 technology is supported by the .NET framework, which impacts macro development at three levels in comparison with VBA:

  • Startup time: In general, Dassault Systèmes makes no commitment whatsoever regarding VSTA performance and will not accept any performance regression as compared to VBA integration. You may continue to use VBA with no performance hindering, as VBA remains available alongside VSTA.
  • Build time: VSTA projects are written in C# or VB.NET, which is first compiled and linked into a Common Intermediate Language, resulting in a DLL assembly. For a small project, this phase takes a few seconds to achieve, before the project can actually be introspected or run.
  • Run time: since building large projects can be time-consuming, a cache mechanism is used to avoid systematically rebuilding projects.

Compatibility

This section discusses compatibility.

VBA remains available and fully functional. VSTA integration does not alter the way VBA works.

Limitations

This section describes limitations.

Limitation 1: Complexity

The most visible limitation is a direct drawback of the power brought by this new technology: you must now understand what a programming language is, dealing with issues such as compilation, release/debug modes, using a complex IDE with debugging windows and debugging concepts etc.

As for the language itself, VB.NET is close enough to VBA, avoiding the complexities of C#. Yet, as of January 2015, there is no available tool for an automated migration of VBA projects to VSTA projects.

Limitation 2: Macro naming

In VSTA, the concept of Macro corresponds to C# or VB.NET methods, whereas in VBA it corresponded to modules. To separate actual macros to be listed in the Macros GUI from helper methods or utility methods, a naming rule has been introduced: a macro name must start with "Macro".

Similarly, a macro is basically a sub in VB.NET or a method in C#. Thus, some reserved characters cannot be used (for example, dashes).

Note: The debug entry point CATMain is not listed in the Macros GUI, but is called when debugging using Visual Studio.

Limitation 3: Restart CATIA after VSTA registration

You must restart CATIA after registering VSTA otherwise the opening of macro libraries may fail.

Limitation 4: VSTA cannot be executed from a network share

As with all .NET applications, VSTA assemblies cannot load from a network share unless they are signed by the manufacturer and a specific .NET code execution policy has been set.

For the moment, you will get the error 1711 if assembly loading has failed:

Cannot start VSTA.
CATVSTAIntegration library cannot load.
Make sure that the VSTA runtime is propely installed and CATVSTAIntegration.dll is not loaded from a network share.

To bypass this, you can copy:

CATVSTAIntegration.dll

to a local folder on your computer, and start CATIA again with the concatenated full path. This means that you have to ask your administrator to modify the CATInstallPath variable using the environment editor.

For example, if the variable value was:

\\networkshare\CATIAInstall
where:
CATIAInstall
is the path where CATIA is installed.

the administrator can modify it on your computer to:

C:\temp;\\networkshare\CATIAInstall

This supposes that you have copied CATVSTAIntegration.dll from:

\\networkshare\CATIAInstall\yourOS\code\bin 

into:

C:\temp\yourOS\code\bin

where:

yourOS

is win_b64.