Adding a Geometrical Object to a CATIA part

The CATGeoFactory allows you to create geometry that is not able to be created interactively (i.e. a NURBS surface). However, since the CATGeoFactory only creates geometry, you cannot view it in CATIA unless you make it a feature. There are two ways to do this: with a procedural report or without a procedural report. The option to do it with a procedural report makes the feature parametric, but it is far more complicated. Doing it without a procedural report is much simpiler and will be illistrated in the example below. To read more about how to create a feature using a procedural report (parametric) see the article in the CAA V5 Encyclopedia "Integrating a New Geometrical Feature in the Update Mechanism".

The example below creates a datum feature from a NURBS surface and adds it to the procedural report. See the wiki article Creating a NURBS Surface in CAA RADE for more details on how to create a NURBS surface.

Before making a datum feature you need to make a CATBody. In the case of a NURBS surface, you need to make a skin from the CATNurbsSurface. Then get the result to instanciate a CATBody. See the code below:

CATSurLimits surMaxLimits ;
piSurf1->GetMaxLimits(surMaxLimits) ;
   
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
CATTopData topdata(pConfig);
   
CATTopSkin * pSkinOpe =::CATCreateTopSkin(piGeomFactory,&topdata,piSurf1,&surMaxLimits); 
pSkinOpe->Run();

// Gets the resulting body
CATBody * piSkinBody = pSkinOpe->GetResult();

// Deletes the operator
delete pSkinOpe;
pSkinOpe=NULL;

Next you will instanciate the datum from the CATBody:

CATIDatumFactory_var spDatumFactory;
spDatumFactory = pSpecContainer;
CATISpecObject* oDatumFeature;
spDatumFactory->InstanciateDatum(piSkinBody, oDatumFeature);

Last you update the datum and add it to the procedural view:

oDatumFeature->Update();
spCurObj = oDatumFeature;
spCurObj->InsertInProceduralView();

pConfig->Release();

Note that the CATSoftwareConfiguration was released. This is done to free up memory.