Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

How to get Child features of a SketchFeature

Gears Phenom Gears Phenom
Gears Phenom

Is there some magic to finding the Child Features of a SketchFeature?

In my code I've found a SketchFeature but if I do:

SketchFeature sf;
...
Feature[] children = sf.getChildren();

An empty array is returned!

I only need the Children, but I tried the Parents and that returns an empty array too.

But if I click on the SketchFeature in the part I can see the Child (and Parent) Features highlighted:
SketchFeatureChildren.png

 

One thing to note, I'm finding the SketchFeature by cycling the part using:

tag = ufSession.obj().cycleAll(workPartTag, tag);

Once I get the SketchFeature tag I convert it using the TaggedObjectManager:

SketchFeature sf = (SketchFeature) theSession.taggedObjectManager().get(tag);

I know this is rather convoluted, but its part of a much larger codebase and the cycling is done that way because I'm looking for lots of different object types all at once, so I can't just find it using the SketchCollection.

 

EDIT: I've also tried (with no success) getting the relatives using the UF route:

AskFeatRelativesData featRelatives = ufSession.modeling().askFeatRelatives(sf.tag()); 

UFSession.Any ideas what I'm doing wrong?

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]
3 REPLIES 3

Re: How to get Child features of a SketchFeature

Gears Phenom Gears Phenom
Gears Phenom

Man Frustrated OK, so there was one thing I didn't mention. The SketchFeature I found is inside an instantiated UDF...

If I explode the UDF then I can get the relatives of the SketchFeature (in the image showing the sketch selected, I had already exploded the UDF, but I did an undo afterwards to get back to the original state).

 

So now the question is, is it possible to get the relatives of a (Sketch)Feature that is inside an instantiated UDF?

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]

Re: How to get Child features of a SketchFeature

Phenom
Phenom

Not sure if this will help.  Look at 'UF_MODL_ask_features_of_udf'.  This is supposed find all the features that make up the UDF.

Suresh
Technisites Australia
Production: NX10.0.3 Developing: NX11.0.2.7, NX12.0.2, NX1847,
Development: C++, C# .Net, VB .Net, Python, KF

Re: How to get Child features of a SketchFeature

Gears Phenom Gears Phenom
Gears Phenom

Unfortunately as I'm cycling through the objects I have no idea if the object found is inside a UDF or not. I just want to get it's Child Features.

I only know the Feature is inside a UDF in this particular case as I made the part.

Even if I found the UDF and got it's member Features, that still does not tell me the parent/child hierarchy between the Features.

 

This whole issue about finding the Child Features came about because while cycling the objects I came across an object that causes a complete crash of NX when trying to get the NXObject from the Tag using TaggedObjectManager.

Using C# trying to get the NXObject throws a nice catchable exception that states it is of type ScalarPoint but there is no NXOpen equivalent. But in Java (our chosen development language) trying the same thing crashes NX.

 

I know that this object type is created by an "Extreme Point Measurement" Feature, so I was trying to walk up/down the Feature tree from the ScalarPoint's parents looking for an "Extreme Point Measurement". If I found that , then I could ignore this tag.

 

As you can see from my signature we're on NX8.5. I've tested this code in NX12 and it works fine and as NX8.5 is now out of maintenance there's no way I'll get a fix for it.

We are (finally) migrating to NX12 over the next few months, so I'm going to give up on this and just wait until then I think.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Dell 7530 Precision, Win10, 32GB. Developing in: Java | C | KF
Production: [NX12.0.2 MP1]