06-02-2011 02:43 PM
I wanted to detail the steps I found, so that others could more easily follow what I found going through these discussions. While there are numerous examples, they lack details such as function names and how to achieve the steps. Most of them seem to cover only arrays. I welcome corrections. I'm not saying this is the best way; it is, however, a simple detailed description of one way to do it.
I wanted to create a cluster of various data types that could then be manipulated by name. Unfortunately, simply wiring an existing cluster to a Bundle by Name.vi does not assign the existing labels of the elements to the name field of the cluster. I don't know why.
1. Create an input cluster with dummy constants of the proper data type for each element.
How do you create an input cluster? Searching functions finds no "Input Cluster" function.
The only way I found was to place a dummy Bundle by Name.vi , right-click at the top of the leftmost of the two rectangles and select Create, then Constant. The result looks like the attached Creating Input Cluster.PNG
You might as well delete the Bundle by Name.vi at this point, because the changes make to the input cluster will only be reflected when it is connected to a NEW Bundle by Name.vi
Next, for my purposes, I needed constants for DBL numeric, string, and array of strings. I started by placing one DBL and one string constant on the block diagram. I copied these to create the ones I needed. Make the labels visible and type in the names corresponding the Bundle Names desired.
Since there is no function called "String Array constant", it is necessary to place the "Array Constant" function on the Block Diagram, then drag a string constant into the empty right hand square of the Array Constant. It immediately changes color to show it is a string array.
Drag each of these constants into the input cluster so that they appear in the order desired. It is a bit of a pain because the square resizes tightly around the existing elements after each insertion. You have to keep expanding the box at the bottom by dragging its sizing handles, so you can be sure each item is added to the bottom of the list. When done, my input cluster looks like Completed Input Cluster.png attached.
2. Place a NEW Bundle by Name.vi on the Block Diagram. Wire the input cluster to the top of the left rectangle of the function. Drag the down sizing handle of the Bundle by Name.vi until all the elements of the cluster are visible. You will see the names and it will look like Bundle by Name with assigned names.png attached.
3. All that remains is to connect the data wires for the individual elements to the left side of each named block and wire the output cluster. The result is shown in Complete design producing cluster of named elements.PNG attached. (Since only three attachments seem to be allowed, this last will be in a follow-up post.)
06-02-2011 02:44 PM
The final result is shown as Complete design producing cluster of named elements.PNG, which is attached.
06-02-2011 02:53 PM
Thses may be of interest to you.
One describes a short-cut similar to your write-up and the other one tells how to be dangerous.
02-03-2012 07:54 AM
I know this is over 6 months old but...nice job!! Exactly what I was looking for.. Maybe "bundle by name" is a misnomer. More like "replace by name".
12-07-2012 02:01 PM
I wanted to add a brief statement about EDITING cluster controls because newcomers to cluster usage (like myself). The HELP is good on creation but says nothing about modification. While it has been posted other places, I think a "newbie" might appreciate getting this info here.
To edit a cluster control, open the CTL file, then
Add a control by creating the control on the front panel, then save the control.
To remove a a control, delete the control, then save the control file.
To modify an existing control
1. Move the control out of the cluster into a blank VI.
2. SAVE the cluster control file (CTL).
3. Modify the control in the blank VI.
4. Drag the modified control back into the cluster control.
5. SAVE the cluster control file (CTL)
NOTE WELL: don't skip step 2.
12-07-2012 04:00 PM
When creating clusters you should always work with typedefs. It makes maintaining them much easier since copies of a typedef will get updated to reflect canges to the cluster definition.