Reply

How to get the BodyFeaturePtr

[ Edited ]

Hello,

 

I want to analyse the features of the PartDocument (V17).

 

PartDocumentPtr pPart;

 

ModelsPtr pMs = pPart->GetModels();

int MCount = pMs->GetCount();

 

for(int i = 1 ; i

{

ModelPtr pM = pMs->Item(i);

FeaturesPtr pFs = pM->GetFeatures();

for(long j = 1; j GetCount(); j++)

{

BodyFeaturePtr pF = pFs->Item(j);//// Error! pF = NULL

FeatureInfo* featureInfo = _featureAnalyzer->analyze(pF, pDocDispatch);

}

 

}

 

any ideas?

Thanks

 

Posted by: Julia Schneider
Post date: 5/27/2007 11:51:35 PM

2 REPLIES

RE: How to get the BodyFeaturePtr

[ Edited ]

Julia,

 

Everything that I read in the SDK indicates that it should work. To quote the SDK, "The BodyFeature object is the base feature object in the Features object collection."

 

It would appear that this is not a true statement. You would figure that there would be SOME base interface to work with but I can't find one. You may submit an IR to GTAC to see what they say.

 

In the mean time, you can always do it the hard way via IDispatch. Here is some sample code to get you going if you choose that route.

 

 

 

HRESULT hr = S_OK;

SolidEdgeFramework::ApplicationPtr pApplication = NULL;

SolidEdgePart:artDocumentPtr pPartDocument = NULL;

SolidEdgePart::ModelsPtr pModels = NULL;

SolidEdgePart::ModelPtr pModel = NULL;

SolidEdgePart::FeaturesPtr pFeatures = NULL;

SolidEdgePart::BodyFeaturePtr pBodyFeature = NULL;

FeatureTypeConstants nFeatureType = (FeatureTypeConstants)0;

 

CoInitialize(NULL);

 

pApplication.GetActiveObject(_T("SolidEdge.Application"));

pPartDocument = pApplication->ActiveDocument;

pModels = pPartDocument->Models;

 

for (long i = 1; i Count; i++)

{

pModel = pModels->Item(i);

pFeatures = pModel->Features;

for (long j = 1; j Count; j++)

{

// QueryInterface returns E_NOINTERFACE

//hr = pFeatures->Item(j)->QueryInterface(__uuidof(SolidEdgePart::BodyFeature), (void**)&pBodyFeature);

//pBodyFeature = pFeatures->Item(j);

 

DISPID rgDispId = 0;

OLECHAR *Names[1] = {L"Type"};

 

hr = pFeatures->Item(j)->GetIDsOfNames( IID_NULL,

Names,

1,

LOCALE_USER_DEFAULT,

&rgDispId );

 

if( SUCCEEDED(hr))

{

VARIANT varResult;

VariantInit(&varResult);

V_VT(&varResult) = VT_I4;

DISPPARAMS disp = { NULL, NULL, 0, 0 };

 

hr = pFeatures->Item(j)->Invoke( rgDispId,

IID_NULL,

LOCALE_USER_DEFAULT,

DISPATCH_PROPERTYGET,

&disp,

&varResult,

NULL,

NULL );

 

if( SUCCEEDED(hr) )

{

nFeatureType = (FeatureTypeConstants)(V_I4(&varResult));

switch (nFeatureType)

{

case SolidEdgePart::igChamferFeatureObject:

break;

case SolidEdgePart::igExtrudedCutoutFeatureObject:

break;

}

}

}

}

}

 

pBodyFeature = NULL;

pFeatures = NULL;

pModel = NULL;

pModels = NULL;

pPartDocument = NULL;

pApplication = NULL;

 

CoUninitialize();

 

 

Posted by: Jason Newell
Post date: 5/29/2007 1:09:52 PM

Re: RE: How to get the BodyFeaturePtr

Hey there,
is there still no easy solution to get a `Feature` out of a Features collection?

Im working with ST8, and the issue seems to be still there...