Data Table into Array


I have Data Table of Elements, each element contains parameters like Name, ProtonNumber, Weight, etc…

And I would like to convert it into array of elements.
So I created element class, as you can see below, it is dummy class just for holding variables.

And in Level Blueprint I want to fill array with these elements as you can see below.

Index of array should be ProtonNumber (because it is unique and it is number), and others parameters like Symbol, Name, Weight etc… should contain elements in that array.

For example array with index 1 (pseudo code):


How to convert it?

Instead of Setting the array, Get it and Add element. Something like this:

The array type needs to match whatever the loop is spitting out, of course.

1 Like

But it is array of names and I need to convert it somehow to array of my custom elements as you can see below.

What is a BP Element? A component, an actor? Anyway, you can’t directly compare a piece of text with an object… There is no conversion.

Your DataTable holds structs, you can populate your array with structs.

You can spawn (SpawnActorFromClass node) objects / components and feed them data from the Data Table and then add those objects / components to an array. I believe this is what you’re trying to achieve.

As I said BP Element is just dummy class (actor with no logic) only hold these variables.

Equivalent to C++:

class Element {
      double a;
      double b;
      double c;
std::vector<Element> element;

So what’s the problem then? Spawn the actor (instantiate), feed it DataTable struct/variables, add the actor to the array.

You can either have your dummy hold the struct or use separate variables - you can even expose them on spawn, making them easier to set.

Something like this:

But this spawns it in the world, right? I don’t want to spawn it in the world, just make array in the background.

Yes, they spawn in the world - persistent level. Just keep it hidden.
If you just make an array of objects, it will be a linked list of null pointers since no objects were instantiated.

If you want pure data, keep it as a struct.

You seem to want objects, but you don’t want to construct them?

Yup, you can keep it as a struct array. Easier to manipulate, iterate and so on; especially that you cannot write anything back into the DataTable.

For anyone with some programming background, blueprints may seem somewhat awkward at times :slight_smile:

Yes I want only pure data without any other logic or construction, so I left it as array of struct (I didn’t know that option).

I want object (class) like in programming language like:

class Element {
       double a;
       double b;
       double c;

And struct looks like this, so I don’t need that BP actor :slight_smile: Thank you