Adding a rectangle to a sketch programatically
 We create a rectangle in a 2D sketch by specifying 2 points. You get the points from transient geometry object, but they need to be used to create the two SketchPoint things.      // Get the transient geometry object. We'll use this to create pure geometric points    CComPtr pTrGeom;    pTrGeom = pApp->TransientGeometry;      // Draw a 4cm x 3cm rectangle with the corner at (0,0)    CComPtr pPt1; // Pure geometric point    hr = pTrGeom->CreatePoint2d(0.0,0.0,&pPt1);       if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" create 2d point failed") ;       CComPtr pPt2; // Pure geometric point    hr = pTrGeom->CreatePoint2d(4.0,3.0,&pPt2);    if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" create 2d point failed") ;       // Create sketch points from above points    // Get list of SketchPoints, points existing in a sketch    CComPtr pSkPoints;    hr = pSketch->get_SketchPoints(&pSkPoints);    if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" get sketch point list failed") ;       // Create a SketchPoint from a geometric point    CComPtr pSpt1;    hr = pSkPoints->Add(pPt1,           // geometrical point                        VARIANT_FALSE,  // not a hole center                        &pSpt1);        // resulting SketchPoint    if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" add point to sketch failed") ;       CComPtr pSpt2;    hr = pSkPoints->Add(pPt2,VARIANT_FALSE,&pSpt2);    if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" add point to sketch failed") ;       CComPtr pRectangleLines;      // Get SketchLines    CComPtr pSkLines;    hr = pSketch->get_SketchLines(&pSkLines);    if (FAILED(hr))        return ReturnAndShowCOMError (hr,L" get lines list failed") ;       TRACE (L"There are currently %d lines in the sketch\n",pSkLines->Count) ;      // Creat a rectangle from two points    hr = pSkLines->AddAsTwoPointRectangle(_variant_t((IDispatch *)pSpt1),                                          _variant_t((IDispatch *)pSpt2),                                          &pRectangleLines);