キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Easier way to convert array to cluster with named variables?

解決済み
解決策を見る

I have an array of variables, I would like to essentially unbundle that array to named variables.

 

I believe the only way of doing this is by converting the array to cluster (besides removing each element one by one)?

 

Is what I have done below the best way of doing it? seems a bit weird having to unbundle and rebundle by name.

 

comments appreciated.

 

example array to cluster with name.png

 

 

0 件の賞賛
メッセージ1/14
11,919件の閲覧回数

You can use the Array to Cluster node to do the conversion for you. The tricky part is the name matching. If the first element in your cluster is always going to be the first element in the array, it works fine. But as soon as you add a new cluster element, you will run in to trouble. The Bundle by Name eliminates this problem by using the names and is really the only way to make sure your names always match up with the right array element.

 

To clarify, you don't need the Bundle by Name to wire the bundle straight in to the indicator you have, but in order to get those names in the Unbundle by Name node, you do.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 件の賞賛
メッセージ2/14
11,897件の閲覧回数

Also, you should make that cluster into a Typedef, for future expansion.

0 件の賞賛
メッセージ3/14
11,889件の閲覧回数

Thanks for the reply.

 

The first array element will be the first cluster element, and the rest of the elements will be in the same order for each.

 

How can I use the array to cluster to add names to the cluster elements?

 

Is there a way to add names to the array elements?

0 件の賞賛
メッセージ4/14
11,885件の閲覧回数

 

Your problem code is actually right before the red square. Instead of the "array-to-cluster-unbudle dance", you should simply use a plain index array resized for the same number of outputs. same functionality, less convoluted.

Your wiring is a bit of a mess and it is hard to tell if the order of elements in the array is the same as in the cluster.  Maybe a simple typecast to the cluster would work.

 

メッセージ5/14
11,866件の閲覧回数

[Deleted]

 

Altenbach to the rescue!

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 件の賞賛
メッセージ6/14
11,863件の閲覧回数

Here is what Altenbach means. This is what you want, right?
Array to Cluster.png

Edit: shoot you can even get rid of the Array To Cluster node in there and just type cast the array.

 

Make sure you Type Def your cluster so you can change those names in the future to keep your code consistent.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


メッセージ7/14
11,852件の閲覧回数
解決策
トピック作成者hydzikが受理

@altenbach wrote:

Maybe a simple typecast to the cluster would work.


Of course it does!

 

 

メッセージ8/14
11,850件の閲覧回数

Note that typecasting has no error checking, so you better make sure that the sizes and types match or you get garbage, of course.

0 件の賞賛
メッセージ9/14
11,836件の閲覧回数

thank you all, this was what I was after.

0 件の賞賛
メッセージ10/14
11,831件の閲覧回数