Hi,
We are trying to create point geometry in opened SolidWorks part using C++ APIs. The point coordinates will be specified explicitly. We are trying to create point using following code.
//=================================================
CComPtr
CComPtr
PS_IF_FAILED_ACTION(SUCCEEDED(m_pSwApp->get_IActiveDoc2(&pCADPart)) && pCADPart != NULL, return E_FAIL;);
CComPtr
PS_IF_FAILED_ACTION(SUCCEEDED(pCADPart->get_SketchManager(&pSketchMgr)), return E_FAIL;);
HRESULT hRes = pSketchMgr->Insert3DSketch(TRUE);
hRes = pSketchMgr->put_AddToDB(TRUE);
CComPtr
hRes = pSketchMgr->CreatePoint(-0.124229, 0.09779, -0.014756, &point);
hRes = pCADPart->ClearSelection2(TRUE);
hRes = pSketchMgr->Insert3DSketch(TRUE);
hRes = pSketchMgr->put_AddToDB(FALSE);
hRes = pSketchMgr->put_DisplayWhenAdded(TRUE);
//=================================================
With the use of above code in callback action (on action of customized button event) in SolidWorks addin, point gets created and displayed in 3D scene.
However if we use the same code inside the "CMacroFeatureManager::Regenerate(IDispatch* app, IDispatch* modelDoc, IDispatch* feature, VARIANT* pOutput)" function then point is not created. The "pSketchMgr->CreatePoint()" API returns the NULL value.
Anybody knows, Why "pSketchMgr->CreatePoint()" API didn't work in CMacroFeatureManager::Regenerate() callback function?
Thanks and Regards,
Mahadev