AnsweredAssumed Answered

How to traverse the FeatureTree?

Question asked by Rongkang Qin on Feb 27, 2019
Latest reply on Feb 28, 2019 by Rongkang Qin

I use the API named "IGetFirstSubFeature"、"IGetNextSubFeature" and "IGetNextFeature" to traverse FeatureTree, but I find it cannot get the part which make up the subAssembly model in the whole model, if we open subAssembly model indenpendent, then we can get the part which make up the subAssembly model.

 

I check the type when I traverse the FeatureTree, I find the subfeature belong to the feature( which type is "reference") cannot be find. Is there anyone help explain it?

 

I traverse the tree as below, maybe it cannot get all the sub-sub-...-Feature, but for the structure showed in the picture, I think it's enough. I can get the subAssembly named "Tolva Mezcldora", But I cannot get the part named "Tolva Mezclado" or "Paletas".

 

 

iModelDoc2->IFirstFeature(&swFeature);

long sonID, fatherID;

 

while (swFeature) {

 

fatherID = 0;

swFeature->get_Name(&strFeatureName);

swFeature->GetTypeName2(&strFeatureType);

swFeature->IGetFirstSubFeature(&swSubFeature);

swFeature->GetID(&fatherID);

 

while (swSubFeature) {

 

sonID = 0;

swSubFeature->get_Name(&strFeatureName);

swSubFeature->GetTypeName2(&strFeatureType);

swSubFeature->GetID(&sonID);

CComPtr<IFeature> swNextSubFeature;

swSubFeature->IGetNextSubFeature(&swNextSubFeature);

swSubFeature = swNextSubFeature;

}

 

CComPtr<IFeature> swNextFeature;

swFeature->IGetNextFeature(&swNextFeature);

swFeature = swNextFeature;

}

 

微信图片_20190227152628.png

Outcomes