Opening a part in an interactive window

#include "CATIIniInteractiveSession.h"
#include "CATSession.h"
#include "IUnknown.h"
#include "CATSessionServices.h"
#include "CATIEditor.h"

CATBoolean OpenPartExample::OpenPart()
	rc = NULL;

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

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

	CATIEditor * pInterSesEditor = NULL ;
	rc = interSession->Open("C:\\tmp\\example_part.CATPart",FALSE,&pInterSesEditor);
	return TRUE;


  • The GetPtrSession call is a global macro used to return the CATSession.
  • In order to open a part interactively (as opposed to batch mode) you must retrieve the CATIIniInteractiveSession from the CATSession. This is accomplished through the QueryInterface method of the CATSession. (If you don't need to open interactively you can use the CATDocumentServices class.
  • Once the CATIIniInteractiveSession is obtained, you can easily open, close, save, save as, etc. using the methods of the CATIIniInteractiveSession.
  • In this example, the Open method returns the CATIEditor of the document. A CATEditor is associated to each document in the session. (see Handling Multiple Parts In One Session).