Replace partion of item e.g 1*4 into 1;1;1;1

Hi,
Challenge:
There is a tree, with multiple lists and items.
The items consists of numbers in between ; ; (e.g. 10;10;15) = ok

However I would like to change the item parts which consist the *

  • represents a multiplication.
    so in this example I would like to modify
    4 *5 --> 4;4;4;4;4
    1 *4 --> 1;1;1;1

And then ultimately the text has to be replaced in the item at the specific location (so the rest of the item is still there)

2020-04-05 list item with multiplication in name.gh (6.3 KB)

I do know there is the replace text command, but somhow it does not work. + do not know how to retrieve the 45 and 14 in a logic manner (note the values could be any other number).
[2020-04-05 list item with multiplication in name.gh|attachment]
Any suggestions?

Thank you in advance :slight_smile:

(your upload links are broken, btw)

I think this is what you’re after - it works by splitting the text at the semicolons, and then by the asterisk. This makes a tree where the first item is the item to be multiplied, and the second is the multiplication value (and if it doesn’t have one, just defaults to being a 1)

The rest is pretty straightforward from there!

200405 SplitMultiplyText.gh (9.0 KB)

1 Like

This would be more simple via coding, i am sure.

ReConstruct Path.gh (12.9 KB)

Simpler…kinda…

ReConstruct Path.gh (16.4 KB)

Hi!
Thank you!
The duplicate data never crossed my mind! But it works perfectly!

If you are ok with it I have 1 more question regarding manipulating the same list.

I would like to split the parts behind the X, Y and Z,
and combine them so I have a list with all the item;
List with X
List with Y
List with Z

I know its possible to split the lists at X,Y,Z with the split list command.
However, how do you know/order if the text belongs to the X,Y or Z?

2020-04-05 Divide into lists of X Y and Z steps.gh (10.3 KB)

Yes thats true.
But this was easy to solve using path mapper :slight_smile:

If you have any suggestion on my second question please let me know :slight_smile:
Thank you

Hi,
Thank you. It works :slight_smile:
If you have any suggestions on my second question (stated below) please let me know.
Thanks again!

2020-04-05 Divide into lists of X Y and Z steps_RE.gh (9.3 KB)

oops that’s my bad - you just need to change the split tree ‘D’ parameter in my solution from 3 to 2. I collapsed the tree a little too much.

1 Like

Hi!
Thank you! :slight_smile:
I implemented it in my model, however came to the conclusion there is still 1 challenge to go:
If there is No XYZ, an empty item has to be added in the list at that location.
Reason for this is, that I can trace back the original command.

All 0 items --> commando 0
All 1 items --> commando 1
All 1 items --> commando 2

any ideas?

thanks again!

2020-04-05 Divide into lists of X Y and Z steps_RE_RE.gh (15.2 KB)

You could test for Text Length, and replace items of 0 length with whatever you would like to sit in those spots

Thanks for your quick response.
But the point is I would like to ‘add’ the empty items.
In Grey is what we have at the moment.
In yellow what I would like to have.
I would like to do this because then I will be able to trace back to which original commando it belonged 1,2,3 (because the branch/path names dont trace back that far).

Or do you have another suggestion?

thanks again!

How about this? I split the list twice, once to get the numbers, and again to get the XYZ’s. Then you determine what’s missing from the XYZ list, and insert an ‘empty’ at that location, in the other list.

It will break if it ever receives anything other than XYZ, a number, or a semicolon, though!

200405 SplitMultiplyText.gh (11.4 KB)

(edit: added the result panel at the end)

Thank you ! :slight_smile:
It does exactly what is needed.
Because you are very good in List manipulations, maybe you can solve the challenge which I have posted a while ago and noboday seems to have the answer. There is one answer given but that not what I was looking for.

Thank you once again!
and if you need some additional information.

Please let me know!
Thanks :slight_smile: