×
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

NX8 - Journal - Filtering GetAllObjectsonLayer

NX8 - Journal - Filtering GetAllObjectsonLayer

NX8 - Journal - Filtering GetAllObjectsonLayer

(OP)
I am using

CODE

allObjects = workPart.Layers.GetAllObjectsOnLayer(lay) 

To get all of the objects on layer "lay" in my list. However, I actually only want to keep objects of type curve, point, solid body or sheet body in that list and no other types.

How I can filter out my list?

Thanks,
Jeff

RE: NX8 - Journal - Filtering GetAllObjectsonLayer

I'd suggest creating a list for each type of object you are interested in then loop through your array of objects, use the TypeOf() operator to determine what type of object you have and add it to the appropriate list.

CODE --> psuedocode

for each someObject as TaggedObject in allObjects
    if TypeOf(someObject) is NXOpen.Body then
        theBodyList.add(someObject)
    end if
    if TypeOf(someObject) is NXOpen.Point then
        thePointList.add(someObject)
    end if
    ...
    etc
    etc
next 

www.nxjournaling.com

RE: NX8 - Journal - Filtering GetAllObjectsonLayer

(OP)
But if I put the objects into an ArrayList() how do I get it out again as NXObject() - which is the type I need to work with?

Thanks,
Jeff

RE: NX8 - Journal - Filtering GetAllObjectsonLayer

Don't use an ArrayList, use a list of the type you need. Avoid ArrayLists entirely.

If you don't need to access the different object types individually (e.g. you are going to change the layer or color of all the objects simultaneously), I'd suggest creating one list of type NXObject (or, for my example, DisplayableObjects). The logic in the example above still holds, you would still loop through your existing array and look for the object types of interest. When one is found, add it to the master list instead of individual lists. If a function or method requires an array as input, you can use the list's .ToArray method.

CODE --> psuedocode

Imports System.Collections.Generic
.
.
.
Dim masterList as New List(Of DisplayableObject)

for each someObject as NXObject in allObjects
    if TypeOf(someObject) is NXOpen.Body then
        masterList.add(someObject)
    end if
    if TypeOf(someObject) is NXOpen.Point then
        masterList.add(someObject)
    end if
    ...
    etc
    etc
next

Dim displayMod1 as DisplayModification
.
.
displayMod1.NewColor = 123
displayMod1.Apply(masterList.ToArray)
displayMod1.dispose
.
.
. 

www.nxjournaling.com

RE: NX8 - Journal - Filtering GetAllObjectsonLayer

(OP)
Thanks Cowski! I think I get it now.

Jeff

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