Hello, Have been stuck with the correct usage of IGetAppliedAnnotations in my C++/COM code. Here's what I'm doing, given a IDimXpertFeature *pDXPFeat, I call:
long annotCnt = pDXPFeat->GetAppliedAnnotationCount();
IDimXpertAnnotationPtr pDXPAnnots = pDXPFeat->IGetAppliedAnnotations(annotCnt);
// Now iterate over the array of annotations
for(int i = 0; i < annotCnt; ++i)
{
BSTR dxpSWAnnotName;
swDimXpertAnnotationType_e eAnnotType; pDXPAnnots[i].get_Type(&eAnnotType); } // Works fine only for the first annotation, but all the next entries in the array are corrupt!!!
The API documentation says that IGetAppliedAnnotations retuns a pointer to an array of IDimXpertAnnotations. But, seems like the above function signature returns a pointer to just the first IDimXpertAnnotation under that DimXpertFeature.
Any ideas on what I'm doing wrong here???
FYI - To use the DimXpert APIs, I imported the swdimxpert type library and upon compilation, got the automatically generated header and implementation files (swdimxpert.tlh and swdimxpert.tli) with the following function signature for this API call:
inline IDimXpertAnnotationPtr IDimXpertFeature::IGetAppliedAnnotations ( long Count )
I've not used these COM smart pointers (such as, IDimXpertAnnotationPtr) before, so it's very likely that I'm completely missing the point when it comes to using the correct syntax accessing the returned array of these annotation pointers.
Please enlighten if anyone knows how!!!
Thanks.
Never had to import type libraries for using other SolidWorks APIs before, just had to include their header files and that's it. But did not find any header files for dimxpert in the installation (just a type library).