CATIA CAA API Help – 2

Do you want to apply a color to:

– the whole solid body
– or features within the body
– or faces ?

You can set the color of the main part body using
CATIPartRequest::GetMainBody to get the body and CATIVisProperties on that body.
I don’t have experience with the other cases.
Here’s my code which starts from a CATDocument. If you have another CATPart-related interface you might be able to skip some steps below:
// input is CATDocument *pDocument

CATIPrtContainer_var spiPrtCont;

//retrieve a CATIContainerOfDocument interface on the CATPart document
CATIContainerOfDocument * piContainerOfDoc = NULL;
hr = pDocument->QueryInterface(IID_CATIContainerOfDocument, (void**) &piContainerOfDoc);
if (FAILED(hr) || (piContainerOfDoc == NULL)) {
// cout<< “Cannot find interface CATIContainerOfDocument on CATPart” <<endl;
return E_FAIL;
}

//with this interface, retrieve the specification container
//Note: the specification container (CATPrtCont), contains the mechanical features
// of a document
CATIContainer *piSpecContainer = NULL;
piContainerOfDoc->GetSpecContainer(piSpecContainer);
piContainerOfDoc->Release();piContainerOfDoc=NULL;
if (piSpecContainer)
{
spiPrtCont = piSpecContainer;

piSpecContainer->Release();piSpecContainer= NULL;
if (!!spiPrtCont)
hr = S_OK;
}
//———————————————//
// 3 – Retrieve MechanicalPart feature //
//———————————————//
//cout << ” — Retrieve MechanicalPart feature –” << endl;
CATISpecObject_var spPartAsSpec = spiPrtCont->GetPart();
if (spPartAsSpec == NULL_var)
return E_FAIL;

CATIPartRequest_var spPartAsRequest= spPartAsSpec;
if (spPartAsRequest == NULL_var)
return E_FAIL;

//—————————-
// 4 – Retrieve MainBody
//—————————-
//cout << ” — Retrieve MainBody –” << endl;
hr = spPartAsRequest->GetMainBody (“”, spUKMainPartBody);
if (spUKMainPartBody == NULL_var)
return E_FAIL;

Advertisements

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