Mechanical Modeler

Managing Applicative Mechanical Imports

Using CATIMmiMechanicalImportApplicative

Technical Article

Abstract

This article explains what are the Mechanical Import,  how to create them in order to retrieve information on them.


What is A Mechanical Import?

The Result of the Copy

A mechanical import is a mechanical feature which is the result of the copy of another mechanical feature.  You know [1] that in the general case there are three kinds of copy:

The wording "mechanical import" comes from that the conditions of copy are the following:

It means that in the target 3D Shape, the copied feature ( the mechanical import ) has a link to the original feature which is inside another 3D Shape.

Doing a Mechanical Import by Code

By CAA code, there are two means to create a Mechanical Import:

If you use the CATIMmiInterPartCopy interface, do not forget to use

The Mechanical Import feature is the result of the copy. Generally it is the feature returned by the Run method. It is true for the following mechanical features : point, line, plan, curve.  But it is not true for the following cases:

Here Body.2 , on the right, is the copy of PartBody, on the left. Body.2 will be the feature returned by the Run method, but the real result of the copy is the feature Solid.1 . Solid.1 is the Mechanical Import.

On the right-top, Ordered Geometrical Set.6 is the result of the copy of Orderered Geometrical Set.2 , on le left. Ordered Geometrical Set.6 is the feature returned by the Run method, but the Mechanical import features are features contained inside Geometrical Set.6 (here one but it can several).

On the right-bottom, Geometrical Set.5 is the copy of Geometrical Set.1, on the left. Geometrical Set.5 is the feature returned by the Run method, but the Mechanical import features are features contained inside Geometrical Set.5.

Here Sketch.2  is the copy of another sketch. Sketch.2 will be the feature returned by the Run method, but the Mechanical Import  is the feature Copy.1.

Characteristics of an Import

The characteristics of a mechanical import are

It is the original feature, those which has been copied.

Retrieving the Import Characteristics

These information can be retrieved thanks CATIMmiMechanicalImportApplicative interface.

But you cannot retrieve these two information if you are not authorized to retrieve them. The authorization mechanism is simple:

In the both cases, you cannot call the GetPointedElement or the GetSourceProduct methods without calling a specific method of the CATIMmiMechanicalImportApplicative interface for an authentification step. It is detailed just below.

The Startup File Identifier

The specific method to be able to retrieve the import information is SetPointedElementClientId method. The argument of this method is a string which is the key to open the startup file (startup catalog) which defines the original feature. This key is defined when the catalog is created. Here is an extract of the use case creating a catalog of StartUp [3]

...
CATICatalog *piCatalog = NULL;
CATUnicodeString storageName = argv[6];
HRESULT rc = ::CreateCatalog(&storageName,&piCatalog);
CATUnicodeString clientId("MyCLientId");
 
piCatalog->SetClientId(&clientId);                     
...

MyclientId is the key to be able to open the catalog. It is the same key that you use with SetPointedElementClientId

...
CATIMmiMechanicalImportApplicative * pIFeatureResult = ... ;
pIFeatureResult->SetPointedElementClientId(&clientId);                     
...

Identifier on the Copied Feature

There is another way when you are not the owner of the Startup catalog, or you do not know its identifier. The application copying features can "expose" a special identifier. This identifier is a GUID [5] . This identifier is associated with the copy when it is created.  The process is the following:

...
GUID MyApplicativeImportID = { 
    0x7c7b3737,
    0x5358,
    0x0000,
    {0x02, 0x80, 0x02, 0x0b, 0x3e, 0x00, 0x00, 0x00}
  };               
...

This definition is set in a header file, MyApplicativeImportID.h file .

Case with CATIMmrInterPartCopy

...
#include "MyApplicativeImportI.h"
CATIMmrInterPartCopy *pIInterPartCopy = ...

pIInterPartCopy.SetImportApplicativeId(MyApplicativeImportID);

...
CATISpecObject_var ResultCopy ;
pIInterPartCopy->Run(ResultCopy );
...

Case with selection agent

...
#include "MyApplicativeImportI.h"
myStateCommand::BuildGraph(...)
{
    ...
   CATFeatureImportAgent* pSelectionAgent   = new CATFeatureImportAgent ( ...) ;
    ...
   pSelectionAgent-> SetImportApplicativeId(MyApplicativeImportID);
}          
...
...
#include "MyApplicativeImportI.h"
CATIMmiMechanicalImportApplicative * pIFeatureResult = ... ;
pIFeatureResult->SetApplicativeId(MyApplicativeImportID);                     
...

[Top]

CATIMmiMechanicalImportApplicative Usage

This interface is implemented on the GeometricalElement3D feature which are coming from a copy.  It is the feature considered as Mechanical Import which implements this interface. You have the detail in the Doing a Mechanical Import by Code section. This interface contains three kinds of method:

SetApplicativeId or SetPointedElementClientId

If one of these two methods is not called firstly, all the other methods of the interface will fail.

About SetPointedElementClientId : attention, this method will fail if the original feature (the pointed element) is not accessible in session. But take care, you could not use the tool methods to do a check or to load the pointed element. You must explicitly load the part document containing the pointed element.

GetPointedElement . This method returns the original feature. This method will fail

GetSourceProduct .  To retrieve the Product instance .  This method will fail if:

These two methods fails if you do not have previously called SetApplicativeId or SetPointedElementClientId.

There are two methods : IsPointedElementLoaded and LoadPointedElement. These two methods are only usable if you use an applicative GUID as authentication process.

IsPointedElementLoaded enables you to know if the pointed feature is accessible, in other words, it enables you to check, before to call GetPointedElement, if the pointed element could be returned. If  the pointed element is not loaded, you can call the LoadPointedElement method. This method will do the necessary to load in memory the Part document. After a successful call to the LoadPointedElement method, the GetPointedElement must success.

Exception

On all mechanical imports created before V5R17, you can retrieve the link information without authentication. SetApplicativeId/SetPointedElementClientId are useless, but the other methods of the CATIMmiMechanicalImportApplicative interface can be used. Up to V5R17, mechanical imports need to be applicative to retrieve information on them.

[Top]


In Short

An applicative mechanical import is an import which is tagged or which points an applicative object. The tag or catalog client id is used to obtain information on the import (such as the pointed element).

[Top]


References

[1] Copying Mechanical Features
[3] Creating StartUps in Catalogs
[5] About Globally Unique Identifier
[Top]

History

Version: 1 [Feb 2007]Document created
[Top]

Copyright © 1999-2006, Dassault Systèmes. All rights reserved.
Special Notices CAA V5 CATIA | CAA V5 DELMIA | CAA V5 ENOVIA