Creating a Sketch
To create a sketch you must first create a new part:
There are two ways to create a sketch which are:
1) By Reference Planes
First get the variable for the part
CATIPrtPart_var spPart(pIPrtContOnDocument->GetPart()); pIPrtContOnDocument->Release();
With the part variable you can get the reference planes from the part
CATLISTV(CATISpecObject_var) spRefPlanes = spPart->GetReferencePlanes();
Then to create the sketch we will use the XY plane (spRefPlanes[1])
CATISketchFactory_var spSketchFactory(pSpecContainer); if ( NULL_var == spSketchFactory ) return (CATStatusChangeRCCompleted); CATISketch_var spSketch(spSketchFactory->CreateSketch(spRefPlanes[1])); if ( NULL_var == spSketch ) return (CATStatusChangeRCCompleted); spSketch->OpenEdition();
2) By Origin and Directions
Another way to create a sketch is by defining an origin and a pH and pV direction
double origin[3]={0.0,0.0,10.0}; double x_dir[3]={1.0,0.0,0.0}; double y_dir[3]={0.0,1.0,0.0};
Then to create the sketch we will use the origin,x_dir, and y_dir
CATISketchFactory_var spSketchFactory(pSpecContainer); if ( NULL_var == spSketchFactory ) return (CATStatusChangeRCCompleted); CATISketch_var spSketch(spSketchFactory->CreateSketch(origin,x_dir,y_dir)); if ( NULL_var == spSketch ) return (CATStatusChangeRCCompleted); spSketch->OpenEdition();
Congratulations! You now have a sketch to work on.
To see how to create geometry on the sketch see Creating Sketch Geometry.
NOTE: Be sure to close the sketch when you are done using it
spSketch->CloseEdition();