C# NxOpen - Find all Feature Groups in active Work Part

1k Views Asked by At

Hy, in the CAD programm SiemensNX i have an active Work Part. Inside this WorkPart i have some features (for example curves). For this features i create a FeatureGroup, like a folder with documents in the windows explorer. Now i try to find over the programming interface NxOpen all FeatureGroups in the active WorkPart. I do this in C# but any help in VBA should be also ok for me.

I try this:

foreach(FeatureGroup FGroupX in workpart.Features)
{
    do something with current FGroupX ...
}

The "workpart.features" give me an collection of all features in the active WorkPart. But the for-loop chrashes for every feature of this collection which is not from type "Featuregroup".

Is there another suitable solution to find all FeatureGroups in the active WorkPart?

1

There are 1 best solutions below

1
On BEST ANSWER

Solved it with an additional if-check of the feature type:

foreach(Feature curFeature in workpart.Features)
{
    Type type = curFeature.getType();
    if(type == typeof(FeatureGroup))
    {
        FeatureGroup fg = (FeatureGroup)curFeature //explicite conversion to FeatureGroup-Type
        //do something with fg
    }
}