cancel
Showing results for 
Search instead for 
Did you mean: 

Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello everyone!

 

Let's assume I have hole feature, and it makes few holes. NX Open-wise, that means that I have hole package feature and simple hole features. I know how to refer to them. But if I have few hole packages, I don't know how to refer to the holes belonging only to the given package, but not to the others.

 

Can you please help?

17 REPLIES

Re: Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

For example, I have the following entities:

 

Hole Package, Tag 35712, which owns three holes: Tags 35718, 35744 and 35751.

Hole Package, Tag 35758, which owns three holes: Tags 35759, 35766 and 35773.

 

I need to filter only 35718, 35744 and 35751 because they belong to the package 35712.

 

How can this be done?

Re: Working with Hole Package

Siemens Phenom Siemens Phenom
Siemens Phenom

 

The Feature class has a method called GetChildren(), which is documented as follows: 

 

"Returns the immediate child features"

 

So if you call that on your HolePackage feature, I think it should give you the child features.

 

Re: Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Can't get it to work, getting zero legnth array. Perhaps I'm doing something wrong. Do you have an example code?

Re: Working with Hole Package

Siemens Phenom Siemens Phenom
Siemens Phenom

 

My suggestion may not have been spot on - but it seemed like a good idea at the time.

 

We do have an example on the Solution Center website.  Just search for nx_api4968

 

It is called

Sample NX Open .NET Visual Basic program : report all hole features

 

and it looks like it has a section that is specific to the HolePackage.

 

 

Re: Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Thank you! I was looking for C# examples and perhaps that's why I did not find it. But VB example will do.

Re: Working with Hole Package

Siemens Phenom Siemens Phenom
Siemens Phenom

 

 

You can <<sort of>> convert journals from one of the .Net languages to the other like this:

 

Set your user interface -> Journal preference for the language you want, and start recording a Journal - in this case, you would use C# for this.

 

Play the .VB journal, while still recording.

 

Stop recording, and what you did in the VB journal will be more-or-less transmogrified into C#.

 

This is NOT a perfect method for translating, but for a quick way to see the syntax in the other language, it is pretty effective.

 

Re: Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

A curious technique. Thank you for suggestion! Cat Happy

Re: Working with Hole Package

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

I wrote the following code (just a piece of it shown): 

 

            foreach (Feature theFeature in workPart.Features)
            {
                if (theFeature.FeatureType == "SIMPLE HOLE")
                {
                    theFeature.SetUserAttribute(attrInfo, Update.Option.Now);
                }
            }

As you can see, it puts attribute into each hole withing the hole package. But I am a bit concerned, because those simple holes are contained within the Hole Package - therefore I can't access those attributes in interactive. Or at least I don't know how. Hence the two questions:

  • Can such attributes be viewed in interactive mode?
  • Is it a good practice to use attributes assigned to such internal objects?

Re: Working with Hole Package

Phenom
Phenom

"Can such attributes be viewed in interactive mode?"

 

Since the attribute has been applied to an internal feature, probably not.

 

"Is it good practice...?"

 

Depends on your goals. Do you want to convey information to the user? If so, this is not a good way to do it. Do you want to save some information with the holes that is only accessible by your program(s) - something the user won't tamper with? Then this is probably a good method.

 

If you want to avoid applying attributes to internal features, you can check the .IsInternal property of the feature.