02-10-2021 12:30 PM
Hi,
I have a very basic question. I have been using labview with years, but very rarely use clusters. I want to combine cluster 1 and cluster 2, and then use unbundle by name to get any entry to either cluster 1 or cluster 2. The basic bundle will take the names of the first cluster but not the second cluster. How do I combine both clusters and keep all the names?
I am using the labview base edition
Thanks in advance
Michael
02-10-2021 12:42 PM - edited 02-10-2021 12:48 PM
Naming cluster elements is best done by wiring a cluster constant to the top to the bundle node. Make sure all elements have well defined labels.
You are creating a new cluster that contains two clusters. So here is an idea:
Except for very simple cases, I strongly recommend to do all bundle operations "by name". If you rely on the incoming wire name, all bets are off. "By name" offers much better diagram readability and self-documentation of the code!
02-10-2021 12:44 PM
Hi Michael,
@sn900 wrote:
How do I combine both clusters and keep all the names?
The last bundle will keep the names of elements in both sub-clusters…
When you want to use clusters with named elements you should think of typedefinitions and using BundleByName!
02-10-2021 01:14 PM
Hi,
Thanks for your replies, its great to be able to get help, and so quickly too!
You can see in the bottom image, if you hover over the white box, the hand appears, and if you click, the list of names appear, and you can select the desired output.
But, if you click the white box with the pink line, no options appear. The names are not there. I have attached the vi also.
Your help is appreciated,
Michael
02-10-2021 01:37 PM
Hi, I figured out why that wouldn't work.
The two brown lines are two new clusters with the same name, and that won't work. If you assign them each a different name, it works fine.
Instead of forming a new pink line of two clusters, one with 2 elements, and one with 4 elements, is it possible to form a single cluster with 6 elements. It would be a bit like conjugate building of an array?
Thanks
Michael
02-10-2021 01:40 PM - edited 02-10-2021 01:41 PM
Hi Michael,
@sn900 wrote:Instead of forming a new pink line of two clusters, one with 2 elements, and one with 4 elements, is it possible to form a single cluster with 6 elements. It would be a bit like conjugate building of an array?
Use just one Bundle(ByName) node instead of those two individual ones on the left side of the code.
You cannot "build a bigger cluster from two smaller clusters" like you can do with arrays. Either use the larger cluster right from the beginning or unbundle the smaller clusters and bundle all elements into a bigger one…
02-10-2021 01:56 PM
@sn900 wrote:
Instead of forming a new pink line of two clusters, one with 2 elements, and one with 4 elements, is it possible to form a single cluster with 6 elements. It would be a bit like conjugate building of an array?
Clusters are fixed at run time. Typically you should decide on a good data structure from the beginning. Using "by name", you can easily update parts in different locations, e.g. as follows:
02-10-2021 02:09 PM
@sn900 wrote:
Instead of forming a new pink line of two clusters, one with 2 elements, and one with 4 elements, is it possible to form a single cluster with 6 elements. It would be a bit like conjugate building of an array?
Here's one possibility, but I would very strongly advise against it 😄
02-11-2021 03:40 AM
Thanks for your replies,
I will make sure to put all the constants into the first bundle. I will assign a special vi to build each bundle, then if I want to alter the bundle, I will only need to alter it in one vi.
Thanks
Michael