Search code examples
c#visual-studiocatia

Catia V6 - Escaping out user selection box causes error


I am developing an application in C#, part of which requires an interactive user selection using the inbuilt function:

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

This presents a window in the Catia session -that I lack the rep to add a picture of...

Which is all fine and dandy if the user can find the correct geometry on-screen.

If they press the escape key which this UI is active, it rightly disappears.

But, if the script is restarted (after an Escape press), I get a COM exception whenever this interactive selection window is requested again:

The script is badly written. Since the beginning of the script execution, the user pressed the Escape key, and the script did not exit. See Selection.SelectElement documentation

Which prevents the window from re-displaying. The only way that i've found to make the problem go away is to restart the Catia session - fine for me during debug/testing, but not a viable solution for our designers, who won't want to have to reload what they're working on.

Dassaults Automation documentation is quite frankly shocking, and I've had no joy finding a solution in there.

How can I have avoid this error when escape is pressed? I'm hoping it's not a Catia-specific issue, but I'm relatively new to creating standalone apps.


Solution

  • So, eventually and after investigating with colleagues, this is a massive bug in the Catia application.

    We found no way to prevent this problem, other than finding a workaround that does not rely on the "SelectMultipleElements" function