LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Most efficient way to convert a cluster of clusters to an array

I have a large cluster of clusters. All of the clusters are numeric but do vary between doubles and integers. In my particular case the cluster contains 12 clusters of different sizes. In total, the clusters contain 166 numbers. I want to convert this cluster into an array of clusters. The cluster in the array would be a name and a value. It is fine if the numeric type for this array of cluster is all defined as doubles. The brute force method would be to use a for loop with a case structure to unbundle each cluster and build the array for each cluster. However, if the cluster is modified this VI would have to be modified as well. I was hoping to use the Variant Type Info VIs to pick through the data. The problem here though is that I get all of the type information but lose the actual data when converting the cluster to a variant. Here is the basic idea I have but need a way to get to the actual data.

 

Convert Cluster to Array.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 1 of 3
(634 Views)

The OpenG variant tools can do this with minimal code (convert to array of variants, get the names of the internal cluster elements and for each one get the value by name and convert from variant to double). The MGI tools might too.


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(624 Views)

Just change the 1st variant method on the Main method to a Variant to data and change it to an Array of Variants, then it retains the values.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 3
(597 Views)