LabVIEW Idea Exchange

About LabVIEW Idea Exchange

Have a LabVIEW Idea?

  1. Browse by label or search in the LabVIEW Idea Exchange to see if your idea has previously been submitted. If your idea exists be sure to vote for the idea by giving it kudos to indicate your approval!
  2. If your idea has not been submitted click Post New Idea to submit a product idea to the LabVIEW Idea Exchange. Be sure to submit a separate post for each idea.
  3. Watch as the community gives your idea kudos and adds their input.
  4. As NI R&D considers the idea, they will change the idea status.
  5. Give kudos to other ideas that you would like to see in a future version of LabVIEW!
Showing results for 
Search instead for 
Did you mean: 

Array To Cluster Function, add Type to Convert Cluster

Array To Cluster Function, add Type to Convert Cluster


I rarely use this function, but when I do I always end up using Variant to Data function for my Cluster Type.

So I would like to add a Type terminal to convert cluster type.



If Type terminal is unwired, this function work as it in current version.


If it is wired then it will convert to cluster type, and further it can also be used to define cluster size. So this way we can adjust cluster size dynamically if cluster definition changed.





Trusted Enthusiast

Replace that 'Array to Cluster' with 'Type Cast' and you should be in business.


Yes indeed you are right, I am aware of "Type Cast" would do the job.
But in my opinion if it would be included in "Array To Cluster" function, it would save lots of trouble to beginners. Because in many cases first people will look for "Array To Cluster" function when needed.

Just a thought!


Proven Zealot

I think Darin's point was that as a temporary workaround, Type Cast is a far better choice than Variant To Data because of the performance overhead of Variant To Data -- the data is converted into a Variant at the terminal and then the function converts it back. Really expensive.

Active Participant

I was thinking this just last week.  Especially good if it can set the cluster size automatically too.


@AQ, understood, I fixed the code.

Thanks, :manhappy:

Trusted Enthusiast

Array to Cluster and Cluster to Array are both textbook examples of Type Casting, so I would not dismiss it as simply a workaround, but rather an effective solution that could perhaps be made more accesible to the beginner.  With the power of Type Casting comes the responsibility, AtoC and CtoA help here by greatly restricting the flexibility, perhaps too much.  (I very rarely use these functions).  How many more "Why does my cluster only have 9 elements?" questions do we need?. 


By regaining some of the power, there are potential issues as well.  What happens when a cluster element or elements have different types than the array?  Broken wire(s), coercion, casting?


I would like to see the 'Coerce to Type' function handle clusters so that we could specify the data type (# elements, labels, data types) and at the same time have the values handled in the more natural method of conversion instead of casting.  I think of it as a kindler, gentler Type Cast.


At that point I'd be happy to bag the AtoC and CtoA functions altogether.

Trusted Enthusiast

All this love for the Typecast vs the Variant to Data! Keep in mind one caveat - if you're using mixed datatypes in your cluster, OR if the cluster datatypes are different than the array datatypes - then the Variant to Data is the "better" choice (better defined as more robust, with a speed trade-off, which may be negligible). See demonstration below where Typecast fails but Variant to Data still works:




I'm not a huge fan of CtoA or AtoC - just pointing out a potential pitfall.

Wirebird Labs: Expert Toolkits for LabVIEWDeploy, by Wirebird Labs: Expert Toolkits for LabVIEW
Active Participant

Seems to me that AtoC with a cluster input should simply provide the equivalent of Index Array + Bundle:



Active Participant

Just tried to create an XNode interpretation of this:


David S.
NI Employee (retired)

Jack, would using the secret "Coerce to Type" primitive work in place of the Type Cast in your example?


(For those who don't know about Coerce to Type:

David Staab, CLA
Staff Systems Engineer
National Instruments