I'm trying to find all of the bodies that belong to a feature. In this instance a split body.
I've tried using:
For Each feat As Features.Feature In theSession.Parts.Work.Features If feat.FeatureType = "SPLIT BODY" Then Dim feat_ent() As NXObject = feat.getentities End If Next
But this results in feat_ent being empty.
Is there a way of achieving this?
To partially answer my own question
I've managed to get bodies out by casting to a bodyfeature
For Each feat As Features.Feature In theSession.Parts.Work.Features Dim split_feat As Features.BodyFeature If feat.FeatureType = "SPLIT BODY" Then split_feat = CType(feat, Features.BodyFeature) Dim feat_ent() As NXObject = split_feat.Getbodies msgbox(feat_ent.length) End If Next
This seems a little clunky. If I didn't have a case where it was just a split body and I needed all features that have bodies, is there a simple way to do this without having to add cases for every type of feature that I'd be interested in?
One possible solution would be to iterate through the feature collection, using TryCast to attempt to cast each to a BodyFeature. If it doesn't cast to a BodyFeature, then there are no bodies to return.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX220.127.116.11 MP11 64bit] Testing: [NX18.104.22.168 MP5] & [NX22.214.171.124 MP1]
I've not tried it yet but the TryCast looks like a good workaround.
I do find it odd that the 'Features.Feature' type has the 'ShowBody'/'HideBody' subs but not a 'GetBodies' sub.