Add boolean attribute to Tag Array of Features

Hi, I could need some help
I have recorded a journal to add a Boolean Attribute to some features but I am having trouble to make it generic.
I would like to know if I could use a Feature Tag Array I have to add this Attribute to all features in the array?


Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display

Dim objects1(0) As NXOpen.NXObject
Dim sweepAlongGuide1 As NXOpen.Features.SweepAlongGuide = CType(workPart.Features.FindObject("ROUTE_SWEEP(42)"), NXOpen.Features.SweepAlongGuide)

objects1(0) = sweepAlongGuide1
Dim attributePropertiesBuilder1 As NXOpen.AttributePropertiesBuilder = Nothing
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, NXOpen.AttributePropertiesBuilder.OperationType.None)

attributePropertiesBuilder1.Title = "HAS_VENT_HOLE"
attributePropertiesBuilder1.DataType = NXOpen.AttributePropertiesBaseBuilder.DataTypeOptions.Boolean
attributePropertiesBuilder1.BooleanValue = NXOpen.AttributePropertiesBaseBuilder.BooleanValueOptions.True

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = attributePropertiesBuilder1.Commit()

End Sub
End Module

In your code snippet above, the "objects1" variable is an array. If you add all the desired features to this array before creating the attribute builder, it should apply the attribute to all the features in the array. I would not suggest using a feature tag array as the builder expects an array of NXObjects (passing features is ok because they inherit from the NXObject class).

Are you looking to turn this snippet into a function?

Thank you for the response.
Yes, I think it would be useful to make it as a function.
Anything special I should do in that case?

Best Regards
Gunnar

It isn't required, but personally, I'd use a list object to collect the entities that I wanted to work with. The list object is easier to work with than an array and when you need an array you can use the .ToArray method.