×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX Journal to get a feature's associated body

NX Journal to get a feature's associated body

NX Journal to get a feature's associated body

(OP)
I'm trying to write a journal that let's me select a feature and grab the body associated with that feature so I can do a DisplayModification to it. I tried to record a journal to see how NX does it when you press CTRL + J with a feature selected, but uses sticky references and I can't figure out. Anyone have ideas?

RE: NX Journal to get a feature's associated body

If you have a reference to a feature object, you can use the .GetEntities method to return an array of objects created by the feature. Face and Edge objects have a .GetBody method that will return the body that contains the face/edge. So, as long as the chosen feature creates a face/edge, you should be able to get at the parent body.

As an alternative, why not just prompt the user to select the body? Why does it have to be a feature that is selected?

www.nxjournaling.com

RE: NX Journal to get a feature's associated body

(OP)
Thanks. I'll give that a try tomorrow. It's nice coding in Visual Studio with the NXOpen references added.

The way the journal is going to work is that if there is no selection at runtime, it'll prompt for a selection and filter it to bodies or components. If there is already a selection, and the selection is a feature (extrude, hole, etc.) it'll get the associated solid and apply the modification on it.

RE: NX Journal to get a feature's associated body

(OP)
So I'm doing

CODE --> VB

Dim selectedFeature As Features.Feature = CType(selected, Features.Feature)
Dim selectedEntities As NXObject() = selectedFeature.GetEntities
Dim selectedFace As Object = selectedEntities.GetValue(0)
Dim selectedBody As Body = selectedFace.GetBody 

But I get an error when running with the third line in that block. It says the index is outside the bounds of the array, which makes me think the array returned from .GetEntities is empty. I've also tried selectedEntities.First and it just says there is no First in the array.

RE: NX Journal to get a feature's associated body

I've been tinkering with it a bit and it seems .GetEntities returns empty no matter what. I'd suggest searching GTAC solutions for a working code sample.
http://solutions.industrysoftware.automation.sieme...
If there is no sample, perhaps a call to GTAC to see if .GetEntities is working as designed, and maybe they can whip up a sample and/or provide a workaround.

www.nxjournaling.com

RE: NX Journal to get a feature's associated body

Features covers much more than features that have bodies. Therefore you first have to get the BodyFeature that the feature must have to get the body/bodies. Then using the bodyfeature you can use GetBodies(). Check BodyFeature Class.

Frank Swinkels

RE: NX Journal to get a feature's associated body

(OP)
Frank, that worked perfectly. Thanks a lot!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources