Creating a Point in CAA RADE

Before creating any geometric object in CAA Rade you need to add the following code to your Activate function of your command class:
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
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");
}

The above code gets the editor, the document and the container and checks if they are loaded.

CATIGSMFactory_var spGSMFactory = NULL_var;
CATIPrtFactory_var spPrtFactory = NULL_var;
CATICkeParmFactory_var spParmFactory = NULL_var;
spGSMFactory = pSpecContainer;
spPrtFactory = pSpecContainer;
spParmFactory = pSpecContainer;

The above code sets up factories so you can make your shapes. The GSMFactory has calls to create and modify non-solid geometry (lines, points, etc). The PrtFactory contains functions to create and modify solid geometry (lofts, holes, etc). The ParmFactory contains functions to create and modify parameters (angle, length, etc).


Now that you have these pre-condidtions set up you are ready to make a point.

1) Set up an array of size three (x,y,z) and put your point coordinates into it using the following code:

double Coords[3];
Coords[0] = 0;
Coords[1] = 0;
Coords[2] = 0;

2) Next create a CATIGSMPoint and cast it as a CATISpecObject by using the following code:

CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); //Creates a point
CATISpecObject_var spSpecPoint1 = spPoint1; //Casts the point as a CATISpecObject

3) Finally, if you want to visualize your point in CATIA you must update it and add it to the procedural view. You can do this by adding the following code:

spSpecPoint1->Update();
CATIGSMProceduralView_var spPntObj = spSpecPoint1;
spPntObj->InsertInProceduralView();

Your code should now look like this:

//  Overload this method: when your command gains focus
//
// Activates a command.
//   iFromClient :The command that requests to activate the current one.
//   iEvtDat :The notification sent.
// ----------------------------------------------------
CATStatusChangeRC MyCommand::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
{
	CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
	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");
	}

	CATIGSMFactory_var spGSMFactory = NULL_var;
	CATIPrtFactory_var spPrtFactory = NULL_var;
	CATICkeParmFactory_var spParmFactory = NULL_var;
	spGSMFactory = pSpecContainer;
	spPrtFactory = pSpecContainer;
	spParmFactory = pSpecContainer;

	double Coords[3];
	Coords[0] = 0;
	Coords[1] = 0;
	Coords[2] = 0;

	CATIGSMPoint_var spPoint1 = spGSMFactory->CreatePoint(Coords); //Creates a point
	CATISpecObject_var spSpecPoint1 = spPoint1; //Casts the point as a CATISpecObject

	spSpecPoint1->Update();
	CATIGSMProceduralView_var spPntObj = spSpecPoint1;
	spPntObj->InsertInProceduralView();

	return (CATStatusChangeRCCompleted);
}

Now to run your code

  1. Open a new part file in CATIA
  2. Click the button you made in the Creating a Toolbar CAA RADE Wiki Article

This should create a point at the origin of the part file.