AnsweredAssumed Answered

How to use HoleWizard method to create holes in Standalone Application?

Question asked by Joshua Jiang on Jun 20, 2015

I use C++ to develop in the VS2010 environment.

 

According to the API Help,  Holes can be created in the following codes.

 

     swDocExt->SelectByID2(L"",L"FACE",0.05,0.05,0,VARIANT_FALSE,0,NULL,swSelectOptionDefault,&bRetval);

       hr = swFeatMgr->HoleWizard4(swWzdTap, swStandardGB, swStandardGBTappedHole, L"M8", swEndCondBlind,

       0.0068, 0.02225, 0.016, 0, 0, 0, 0, 2.05948851735331, 1, 0, 0, 0, -1, -1, L"",

       VARIANT_FALSE, VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE, VARIANT_TRUE, VARIANT_FALSE,&swFeat);

 

In the project created by AddinWizard, the code works properly. But in the StandAlone Application the 'hr'variant always returns false(the dot preselected correctly). The code under always returns false,too. I don't know why >_<

     CComPtr<IDispatch> holeDispatch;

     hr = swFeatMgr->CreateDefinition(swFmHoleWzd,&holeDispatch);

 

I get access to the SW with following codes as told in the API HELP:

     CoInitialize(NULL);      

     CComPtr<ISldWorks> swApp;

     HRESULT hres = swApp.CoCreateInstance(__uuidof(SldWorks), NULL, CLSCTX_LOCAL_SERVER);

 

So anyone knows what mistakes I have made? Thank you all in advance!

By the way, It seems C++ is rarely used in developing SW.  Comparing to C# and VB, C++ is in disadvantage?

Outcomes