Transitioning Macros Part 6: Selections

March 27, 2024 Iouri Apanovitch

Welcome to Part 6 of this blog series on Transitioning Macros from CATIA V5 to 3DEXPERIENCE.

For reference, here are all of the blogs in this series:
Part 1: Framework
Part 2: Creating, Opening, and Saving Files
Part 3: Services
Part 4: Product Modeler
Part 5: Part Modeling and Drafting
Part 6: Selections
Part 7: Deployment
---------------------------------------------------------
In this blog I discuss Selections. The good news here – it’s almost identical to CATIA V5.

The differences:

  • The Selection object now belongs to the Editor, rather than to the Document as it was in V5.
  • Some V5 methods have been deprecated. Replaced with new functions.

To get a hold of the Selection object for the current window, in V5 you would write:

01: Dim oSel As Selection

02: Set oSel = CATIA.ActiveDocument.Selection

While in the 3DEXPERIENCE, that would be:

01: Dim oSel As Selection

02: Set oSel = CATIA.ActiveEditor.Selection


Figure 1

The SelectedElement objects are nearly identical. The only difference is that in 3DEXPERIENCE, the object doesn’t have the Document property.

The VisPropertySet objects, which control the graphics properties, are also nearly identical.

The differences lie in the functions/methods. The SelectElement2 and SelectElement3 methods in V5, which enable interactive selections, have been deprecated. Replaced by the SelectElement and SelectMultipleElements methods in 3DX.

The syntax, however, remained the same as in V5. Both selection methods require a filter and a prompt and return a string indicating whether the selection succeeded, as shown below.

  • Func SelectElement (CATSafeArrayVariant iFilterType, CATBSTR iMessage, boolean iMaySkipInteractiveSelection) As CATBSTR
  • Func SelectMultipleElements (CATSafeArrayVariant iFilterType, CATBSTR iMessage, boolean iMaySkipInteractiveSelection, CATMultiSelectionMode iMultiSelectionMode, boolean iTooltip) As CATBSTR

The other methods, such as Copy, Cut, Delete, Paste, etc., are identical to V5.

And that’s it. Nice and easy!

The next post will be the last one where I'll be talking about deploying the macros in the company-wide environment.

About the Author

Iouri Apanovitch

Senior Technical Training Engineer<br><br>As a senior member of the Rand 3D team with a doctorate degree in Finite Element Analysis (FEA) and over 35 years of experience, Iouri provides design, consulting, and training services to those in the aerospace, automotive, electronics, and consumer goods industries. Iouri is a seasoned pro in 3D parametric design and prototyping using knowledge-based engineering methods, and has worked on a wide range of projects including BOM automation, CMM points generation, automated 3D annotation creation, and die tooling automation design. He is also a sought-after instructor and holds the designations of both CATIA Certified Professional (Expert level) and CATIA Certified Instructor.

Follow on Linkedin Visit Website More Content by Iouri Apanovitch
Previous Article
Transitioning Macros Part 5: Part Modeling & Drafting
Transitioning Macros Part 5: Part Modeling & Drafting

Here we look at Part and the Drafting scripting in 3DX which is very similar to V5.

Next Article
Transitioning Macros Part 7: Deployment
Transitioning Macros Part 7: Deployment

In this final blog in the series, we discuss how you deploy the 3DX macros company-wide so other users can ...