Use ..ConvertAll to convert an List (Of Integer) to an array of taggedobject

To all,

I am trying to understand if there is a fast way to convert a List (of Integer) into an array of (NX)taggedobject without looping through each item (of the list)

What I have

Dim ListofFEElmLabel As New List(Of Integer)
Dim theTaggedObjects() As TaggedObject

'I'd like to convert the List into an array of different type

Dim theOutputGroup As CAE.CaeGroup
theOutputGroup = theCAEPart.CaeGroups.CreateGroup("NewgNXGroupName", theTaggedObjects)

Can this be done?

Thanks
Regards

How are you generating the "ListofFEElmLabel" list? Are you iterating through a collection of FEElement objects and storing the .Label property of each? I ask because the FEElement object derives from the TaggedObject class. You could save a list of the FEElement objects then create a group from them with the call:

theOutputGroup = theCAEPart.CaeGroups.CreateGroup("NewGroupName", listOfFEElents.ToArray)

However, if all you have is a list of integers representing the labels, you will need to find the corresponding FEElement of each label and add it to a list (or array) before executing the above statement.

Hi NxJournaling

All you have is a list of integers representing the labels and I currently loop the list and "convert" each label into a FEElement object. I wrote a small function which takes the label and return a CAE.FEElement (if an element exists in the FE model with that label!)

So are we saying that I am stuck with the loop?

Thanks
Regards

Thanks Nx. All I have is a list of Integer, which I am currently passing (a label at a time) to a function which returns a CAE.FEElement if it exists (in the FE model). This approach is under review as a bit ineffective. I was simply hoping to be able to convert the List.ToArray and then somehow change the type of the array. Looks like my approach of loop is valid just needs to optimise it

Thanks
Regards

I don't have enough experience (yet) working with the CAE objects to authoritatively state that you will or will not need a loop. However, based on my current experience, I'm fairly certain that you will end up with some sort of loop.

What does your current loop code look like? Perhaps there are some 'easy' optimizations that we can make.