DMU Space Analysis

Computing the Maximum Separation


This macro shows you how to use distances to compute the maximum separation between selected components (i.e. the maximum of all the minimum distances between a couple of components). 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 result of the macro :

 

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

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

 

CAASpaMaximumSeparation includes seven steps:

  1. Retrieving the selected components
  2. Retrieving the distances collection
  3. Loop on each couple of components
  4. Creation and computation of the distance
  5. Comparison with the maximum value
  6. Clean
  7. Display the results

Retrieving the selected components

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.

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

The number of selected components, iNumber is retrieved using the CountExtract method on the oGroup1 object.

A warning is sent if, at least, two components are not selected.

Retrieving the distances collection

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

Loop on each couple of components

The basic idea of the algorithm is to create a oDistance object for each couple of components.

Each couple is build using imbricated loops and one group iGroup2 which content is changed using AddExplicit and RemoveExplicit methods to add the selected components retrieved using ItemExtract method on oGroup1 object.

Creation and computation of the distance

The oDistance object is created using Add method on the cDistances collection, modified with the FirstGroup method, to take into account the group oGroup2, and then computed with the Compute method.

Comparison with the maximum value

If the result is consistent ( IsDefined method give this information) the value is retrieved using Value method and compared to the current maximum value.

Clean

The environment is cleaned using Remove method group objects.

Display the results

The results are displayed in a Msgbox.

[Top]


In Short

This use case has shown how to use distance in order to compute the maximum separation. Specifically, it has illustrated how to :

[Top]


References

[1] Replaying a Macro
[2] Space Analysis automation objects

[Top]


DMU Navigator Home DMU Space Analysis Home DMU Kinematics Simulation Home

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