Creating Sketch Geometry
To create sketch geometry you must first create a sketch.
Then create the sketch factory by typing in the following code
CATI2DWFFactory_var sketch2DFactory(spSketch);
Next create a few points on the sketch
CATI2DPoint_var spPt_bottom_left, spPt_bottom_right, spPt_top_right, spPt_top_left; double pt_bottom_left[2] = {10., 10.}; double pt_bottom_right[2] = {50., 10.}; double pt_top_right[2] = {50., 50.}; double pt_top_left[2] = {10., 50.};
spPt_bottom_left = sketch2DFactory->CreatePoint(pt_bottom_left); spPt_bottom_right = sketch2DFactory->CreatePoint(pt_bottom_right); spPt_top_right = sketch2DFactory->CreatePoint(pt_top_right); spPt_top_left = sketch2DFactory->CreatePoint(pt_top_left);
With these points we can now make lines
CATI2DLine_var spLine1, spLine2, spLine3, spLine4; spLine1 = sketch2DFactory->CreateLine(pt_bottom_left,pt_bottom_right); spLine2 = sketch2DFactory->CreateLine(pt_bottom_right,pt_top_right); spLine3 = sketch2DFactory->CreateLine(pt_top_right,pt_top_left); spLine4 = sketch2DFactory->CreateLine(pt_top_left,pt_bottom_left);
Then to ensure connectivity of the lines
CATI2DCurve_var spCurve1 (spLine1); CATI2DCurve_var spCurve2 (spLine2); CATI2DCurve_var spCurve3 (spLine3); CATI2DCurve_var spCurve4 (spLine4); spCurve1->SetStartPoint(spPt_bottom_left); spCurve1->SetEndPoint(spPt_bottom_right); spCurve2->SetStartPoint(spPt_bottom_right); spCurve2->SetEndPoint(spPt_top_right); spCurve3->SetStartPoint(spPt_top_right); spCurve3->SetEndPoint(spPt_top_left); spCurve4->SetStartPoint(spPt_top_left); spCurve4->SetEndPoint(spPt_bottom_left);
You can find more ways to create sketch geometry by going to Creating a Fillet.
NOTE: Be sure to close the sketch when are done using it
spSketch->CloseEdition();