Hi,
Thanks for reading this question in advance.
I'm using SolidWorks 2012 SP2, and I'm developing SolidWorks add-in(DLL) using C++ COM in the VS2010 IDE.
What I'd like to implement is to traverse all mates in an assembly and extract all necessary information.
That assembly may contain several assemblies.
So I could create a simple function like this:
VARIANT_BOOL CSwAssembly::GetMateInformation(const CComPtr
{
HRESULT hres = VARIANT_FALSE;
hres = pSourceMate->get_Type(&nMateType);
if(hres == S_OK) hres = pSourceMate->MateEntity(0, &pMateEntity0);
ATLASSERT(pMateEntity0);
if(hres == S_OK) hres = pSourceMate->MateEntity(1, &pMateEntity1);
ATLASSERT(pMateEntity1);
if(hres == S_OK) hres = pMateEntity0->get_ReferenceType2(&nMateEntityType0);
if(hres == S_OK) hres = pMateEntity1->get_ReferenceType2(&nMateEntityType1);
if(hres == S_OK) hres = pMateEntity0->get_ReferenceComponent(&pComp0);
ATLASSERT(pComp0);
if(hres == S_OK) hres = pMateEntity1->get_ReferenceComponent(&pComp1);
ATLASSERT(pComp1);
long nSize;
if(hres == S_OK) hres = pMateEntity0->GetEntityParamsSize(&nSize);
if(hres == S_OK) hres = pMateEntity0->IGetEntityParams(nSize, pEntityParams);
if(hres == S_OK) return VARIANT_TRUE ;
else return VARIANT_FALSE ;
}
And I call this function in the recursive iteration process of traversing the mates from the top assembly.
But sometimes, the pComp0(CComPtr
So I tried to see the reference manual of IMateEntity2::ReferenceComponent() function. And I could find a description there:
'The component instance tree of a subassembly is not loaded because a subassembly does not have a view of its own. Thus, this property returns NULL if the Inplace mate is in a subassembly. '
But I could not know whether an IMate2 can be an IMateInPlace.
The example assembly that I could see the problem is here:
In the "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\api" folder, there is 'wrench.sldasm' file.
I attached two capture images of the mate that makes this problem.
I'd very appreciate if I can any kind of advice from you experts.
SolidworksApi macros