The “Measure Between” measurement tool in CATIA V5 is not exposed to VBA; the macro recorder will not record anything if you try. But there are a few work-arounds in order to measure distance between two points using a CATScript macro.measurement tool not exposed to CATIA VBA

Parameters and Relations Method

The first method is to create a parameter then add a formula to it. Before we create a macro, it’s a good idea to understand exactly how it will work. If you were to do this manually, you would follow these steps:

1. Create a new parameter of type length. Set default value to 0mm and rename it if you want.

catia parameter length macros

2. Click Add Formula.

3. Go to Measures then select distance (Body, Body); Length

catia formula editor

4. Select the two bodies (objects or pieces of geometry) that are to be measured. That’s it!

Now we will recreate this using the following CATScript:

Your CATPart should look like this. Notice the parameter and relation that were created automatically (the measure between shown was created manually to double check the macro worked properly):

how to measure distance between two points catia

This code can be used to measure between more than just two points. For example, you can change it to measure a point to a plane by changing this line of code:

Into this:


SPAWorkbench Method

An alternative method to measure the distance between two points with a CATIA macro is to use the SPAWorkbench properties and methods. This requires a license of DMU. Without the license, the calls will not work. The CATScript code is shown below:

spaworkbench measure

P.S. The GetWorkbench command takes a string as an argument and returns a Workbench object. Each Workbench has an associated ID. To determine the ID of a workbench, open a workbench and the script that can be downloaded here. There’s also a list of workbench IDs in the latest edition of VB Scripting for CATIA V5 here.