Cancel
Showing results for 
Search instead for 
Did you mean: 

Finding group by part of the name

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hello everyone!

How can I find a group by using part of its name? With theUFSession.Obj.CycleByNameAndType can only use full name (right?).

I came up with the following code:

            Tag groupTag = Tag.Null;
            Group theGroup = null;
            string groupName;

            do
            {
                theUFSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_group_type, ref groupTag);
                if (groupTag == Tag.Null) break;

                theGroup = (Group)NXObjectManager.Get(groupTag);
                groupName = theGroup.Name;
            }
            while (!groupName.Contains("<part of the name that I need>"));

Is there a better way to solve the task? Or is it ok?

2 REPLIES 2
Highlighted

Re: Finding group by part of the name

Gears Phenom Gears Phenom
Gears Phenom

I think the only way you can find any object by using only a part of its name is as you described, cycle through all objects of that type and see if its name contains the string you are looking for.

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: Finding group by part of the name

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi @Inch! Thank for the advice!