CATIA CAA API Help – 15

….. Vishal Narayan

CATIGeometricalElement_var geometrical_element = part->GetFeatureSolid();

// This is the main thing.
CATIBRepAccess_var brep_access =
CATBRepDecode(cell,geometrical_element);

CATIPathAccess_var path_access = QUERYINTERFACE(
(CATIBRepAccess*)brep_access,CATIPathAccess
);
CATPathElement* path_element = path_access->ExtractPathElement();

// Now I can place path_element to CSO…

————————————————————-

Just for the reference to other people who might encounter the same problem, this is code I wrote (NOTE: QUERYINTERFACE is our internal macro equivalent to ordinary QueryInterface):

// This is “input”.
CATDocument* document = …;
CATCell_var cell = …;

// Lot of “piping”.
CATInit_var doc_as_init(QUERYINTERFACE(document,CATInit));
CATIPrtContainer_var prt_container((CATIPrtContainer*)
(doc_as_init->GetRootContainer(“CATIPrtContainer”))
);
CATISpecObject_var part_spec_object(prt_container->GetPart());
CATIPrtPart_var part = QUERYINTERFACE(
(CATISpecObject*)part_spec_object,CATIPrtPart
);
CATIGeometricalElement_var geometrical_element =
part->GetFeatureSolid();

// This is the main thing.
CATIBRepAccess_var brep_access =
CATBRepDecode(cell,geometrical_element);

CATIPathAccess_var path_access = QUERYINTERFACE(
(CATIBRepAccess*)brep_access,CATIPathAccess
);
CATPathElement* path_element = path_access->ExtractPathElement();

—————————————————————

The problem come from the CATPathElement that you create.
It is specified in the CATITPSFactoryAdvanced documentation that
the CATPathElement provided must be equivalent to the one
obtained from an interactive selection. It is not the case with
what you do.

Interactively, you can see the CATPathElement of a geometrical selection in 3D by using the Other Selection command available on the local menu.
So you have to create an identical CATPathElement to what is
displayed in the Other Selection command.

So how to create this *&#?#! CATPathElement in the product context?

1) Use methods of CATMfBRepDecode.h to create a selecting object from your topological cell. You get the selecting object as a
CATIBrepAccess Itf.

2) Query Interface CATIPathAccess on the CATIBrepAccess.
The ExtractPathElement method returns a CATPathElement that extend from the selected face to the Part (Top Element).
This Part top element is the reference Product of the instances which are seen in the Product structure.

3) To define on which instance of the Part you want to create
your text. You need to transform the PathElement as follow:
You have to replace the reference Part top element by the
CATPathElement of the instance on which you want to create
the text.
CATIBuildPath interfaces is designed to do that job but
I’m not sure if it is available on selecting object.
To use it, you have to provide a CATPathElement that define the context. Here it should be the CATPathElement of the instance in the product structure.

By this way you can get a CATPathElement equivalent to what
could be obtained from an interactive selection.

You can test your CATPathElement by putting it in the HSO.
If the face is highlighting it is OK.

***************************************************************************************************

Thanks for the input.

I tried to create the CATPathElement in the product context. But still problem exists.
Here is the piece of the code to get CATPathElement in product context.

CATIPartRequest *pPartReq; //retrieved from traversing the tree
CATFace *pFace; // retrieved from traversing the tree
if( NULL != pPartReq )
{
CATIPrtPart *pPart = NULL;
rc = pPartReq->QueryInterface(IID_CATIPrtPart, (void **) &pPart);
if( SUCCEEDED(rc) )
{
CATIBRepAccess_var spBrepAccess = NULL_var;
CATIGeometricalElement_var spGeomElem(pPart->GetFeatureSolid());
CATCell_var spCell(pFace);
spBrepAccess = CATBRepDecode(spCell, spGeomElem);
CATIBRepAccess *pBrepAcess = spBrepAccess;
CATPathElement *testPathElement = NULL;

// get the CATIBuildPath
CATIBuildPath *pBuildPath = NULL;
rc = pBrepAcess->QueryInterface(IID_CATIBuildPath, (void**) &pBuildPath);
if(pBuildPath)
{
CATFrmEditor * pEditor = CATFrmEditor::GetCurrentEditor();
CATPathElement tempPathElement = pEditor->GetUIActiveObject();
// here active UI object is root product
pBuildPath->ExtractPathElement(&tempPathElement, &testPathElement);
}
I tried to get the string representing the CATPathElement using CATIAlias interface. It gave
“Face/Pad.1/PartBody/Part1/Part1.1/Product1”
I guess this is the correct path element (in product context).

Advertisements

One thought on “CATIA CAA API Help – 15

  1. Hi Narayan.

    Can you help me with my problem? I need to create drawing text on drawing and join it with generatedpoint via leader. Then, I need to use InsertVariable method for creating link between 3D parameters and created text.
    In VBA, I can not solve this problem.
    Or, for me is solve to create some parameter to identify 3D point, then create drawing text on drawing and join it with generatedpoint via leader and rename its name by parameter, which is identify 3D point.

    Can you help me with my problem? I am programmer only CAA Automation, this code could it be in DLL.

    Thanks for your answer and help.

    Dave

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s