Creating a New Part in CAA RADE

To create a new part in CAA RADE you will first need to get the active session:

HRESULT rc;
rc = NULL;
CATSession* pSession = NULL;
rc = GetPtrSession(pSession);

Since you are creating a new part interactively (as opposed to in batch mode) you need to create the interactive session:

CATIIniInteractiveSession* interSession = NULL;
rc = pSession->QueryInterface(IID_CATIIniInteractiveSession,(void**) &interSession);

Next, you will get the editor while telling CATIA to make a new part:

CATIEditor * pInterSesEditor = NULL ;
rc = interSession->New("Part", &pInterSesEditor);

If you are creating something other than a part, change the word "Part" (in the code above) to what type of document you want to create. The name is the same as the types listed when you choose File->New in CATIA:

Image:CAT_type.JPG


Now get the form editor, document and container of documents:

CATFrmEditor* pEditor = pInterSesEditor->GetEditor();
if(pEditor == NULL)
{
   printf("error getting the FRM editor");
}
CATDocument *pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConODocs = pDoc;
CATIContainer* pSpecContainer = NULL;
HRESULT hr = spConODocs->GetSpecContainer(pSpecContainer);
if(spConODocs == NULL_var)
{
   printf("error getting the container of documents");
}

You can now make your factories using the container you made:

spGSMFactory = NULL_var;
spPrtFactory = NULL_var;
spGSMFactory = pSpecContainer;
spPrtFactory = pSpecContainer;