Add a circle to a sketch function

Top  Previous  Next

Here's a function for adding a circle to a sketch:


HRESULT AddCircleToSketch (CComPtr<PlanarSketch>& pSketch,

                          const double xCenter,

                          const double yCenter,

                          const double kDiam,

                          CComPtr<Application>& pInvApp)


   CComPtr<TransientGeometry> pTransGeom  ;

   GetTransGeomPtr (pTransGeom,pInvApp) ;


   CComPtr<Point2d> pCenter;



   HRESULT hRes = pSketch->SketchCircles->AddByCenterRadius(pCenter,kDiam/2.0);

   if (FAILED(hRes)) {

       return ReturnAndShowCOMError (hRes,L"AddCircleToSketch but could not add by radius (Outer)\n");



   return (S_OK) ;



Note that this function uses the transient geometry object.


If you don't need that circle itself you can just ignore that last parameter, like this:


   hRes = pSketch->SketchCircles->AddByCenterRadius(pCenter,kDiam/2.0);


...because it defaults to 0.




Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)