NX8 - Journal - Filtering GetAllObjectsonLayer
NX8 - Journal - Filtering GetAllObjectsonLayer
(OP)
I am using
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
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
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 nextwww.nxjournaling.com
RE: NX8 - Journal - Filtering GetAllObjectsonLayer
Thanks,
Jeff
RE: NX8 - Journal - Filtering GetAllObjectsonLayer
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
Jeff