LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TypeDef to Tree

Solved!
Go to solution

I am trying to get code to automatically generate a tree for me based on a enum type def. I have chosen "." to show that the text is on a new level. Any ideas on a simple way to do this? On the left is the typeDef. In the middle is the full list of items in the type def. And on the right is what I would like my tree to look like at the end. For this post I manually filled in the tree. I would like the tags to be the second column. 

Dealcs2_1-1678480724128.png

 

 

 

0 Kudos
Message 1 of 16
(1,298 Views)

You are leaving out a lot of information and we don't even know what your "tyepdef" is (Ring, Enum, etc.), we don't even know why it is a typedef, because that's irrelevant for the problem here.

 

You just need to parse the item names using the period as delimiter and build the tree, right? Have you looked at the help for the tree control?

 

Typically, it would help to attach a simplified VI containing the typedef and the tree so we can play. Staring at a picture of a front panel is not convenient for us to help you.

0 Kudos
Message 2 of 16
(1,254 Views)

Adding the files to the post

0 Kudos
Message 3 of 16
(1,247 Views)

Adding the files...again

Download All
0 Kudos
Message 4 of 16
(1,241 Views)

Can we assume that the items are sorted (alphabetically and numerically (e.g. 3 before 11, etc.)?

 

(Please don not maximize the front panel to the screen!)

0 Kudos
Message 5 of 16
(1,229 Views)

No. They will not always alphabetic order. But they will be grouped with the parent items. 

0 Kudos
Message 6 of 16
(1,214 Views)

for each item in the enum

 split on the last .

  lookup the first part in the item vs treekey map

   if not found, create it recursively (add the parent and store the treekey)

  add a tree item with the last part as name, and the found key as parent

  store the resulting treekey, with full enum string as map key

 

 

0 Kudos
Message 7 of 16
(1,162 Views)

Something like this:

wiebeCARYA_0-1678706456065.png

 

 

Call like this:

wiebeCARYA_1-1678705398140.png

As a bonus, you can do this too:

wiebeCARYA_2-1678705453600.png

To use an enum:

wiebeCARYA_3-1678705502383.png

Or (if the enum is an input to a generic sub vi):

wiebeCARYA_4-1678705568034.png

 

Message 8 of 16
(1,155 Views)

Btw. populating the the becomes exponentially slower with the nr of items in the thee.

 

At some point you might want to hide the tree, populate it and s how it again. Or turn defer panel updates on, populate, turn it off.

0 Kudos
Message 9 of 16
(1,148 Views)

Thanks for the help on this! Is there anyway that you can save in for LV2019? It looks like you are on 2020 and I am still on 2019 😞

0 Kudos
Message 10 of 16
(1,136 Views)