DMU Navigator

Inverting the Selection


This macro shows you how to use groups to invert the selection (i.e. all components that were not selected become selected and vice-versa). The macro assumes that a CATProduct has been loaded and that some components are selected.

This image shows the selection state before the use of the macro :

 

This image shows the selection state after the use of the macro :

 

CAADmuInvertSelection is launched in CATIA [1]. A previously opened document is needed.

CAADmuInvertSelection.CATScript is located in the CAAScdDmuUseCases module. Execute macro (Windows only).

 

CAADmuInvertSelection includes four steps:

  1. Retrieving the groups collection
  2. Creation the group
  3. Inversion of the selection
  4. Deletion of the group

Retrieving the groups collection

The cGroups collection (see Groups ) is the factory to create Group object : this collection is retrieved using the GetTechnologicalObject method, with the string "Groups", on the root product of the active document.

Creation of the group

AddFromSel method is used on the cGroups collection to create the oGroup object containing all the selected components.

Another way to perform the operation can be to create an empty group using Add method, to retrieve the selected components using the Selection object and the add each of them in the oGroup object using the AddExplicit method.

Inversion of the selection

FillSelWithInvert method is used on the oGroup object to fill the selection with all components that are not belonging to the group.

Another way to perform the operation can be to extract all the components that are not belonging to the group, using CountInvert and ItemInvert methods, and to fill the Selection object with them.

Deletion of the group

Remove method is used on the cGroups collection with the oGroup object to clean the session.

[Top]


In Short

This use case has shown how to use groups in order to ease the selection. Specifically, it has illustrated how to :

[Top]


References

[1] Replaying a macro
[2] DMU Navigator automation objects

[Top]


DMU Navigator Home DMU Space Analysis Home DMU Kinematics Simulation Home

Copyright © 2001, Dassault Systèmes. All rights reserved.