Split list, insert values, combine list

Dynamo Hive Mind, I need your help…

I’m working on a script to insert data into our wall type names. Essentially I want to look at the materials in the wall and then generate a concatenated string of material abbreviations (e.g. PLB for plasterborad) which we have on the end of each material name. However I also want to enclose the ‘core’ materials in brackets so the final string would look something link BRK_CAV_(BLK)_PLB (running from exterior to interior)

Now I’ve had some success however there are anomalies I can’t deal with. The script below is a test file (note the A’s and B’s could be any material but for this example A’s are outside the core, B’s inside, I’ve just kept it consistent to get a Boolean mask to split the lists correctly.

**edit : for clarity - I need the solution to work for A and B being variables - e.g. A(C_D)B or B(C_E)F - in every instance the Boolean mask would inform what ‘materials’ are in the core.**

  • Everything works where I have at least 1 material on each outside face of the core.

  • I works where I only have materials outside the core on the exterior face

  • It doesn’t work where I only have materials on outside the core on the interior face - the build-up effectively gets flipped.

  • It doesn’t work at all where I have core materials only.

Anyone got any ideas how I can overcome these issues?

1.3.3-Wall_Core_Test-0.0.2.dyn (18.8 KB)

Thanks for that - interesting bit of script - I really must make an effort to learn a bit of python!

But this will only work if the value is ‘B’ will it not? In realty that value could be anything - i need everything that is in the core in one set of brackets…

e.g. PLB_(TF_CAV_TF)_PLB

That is perfect thanks! I need to make a few tweaks to the rest of my main script to get the right inputs in the right place but that’s nailed it I think. I just need to go and figure out how it works now!

Cheers

K.

1 Like

@erfajo

I never quite got finished with this but back looking at it again now. I’ve hit a couple oddities that don’t seem to work. I’ve tried to pick apart your code but I’ll be honest I don’t really understand some of what is going on, my knowledge of Python is still at a very basic level!!

Can you shed any light on why these combinations don’t work correctly?

Cheers

K.

Home1_Rev01.dyn (11.9 KB)

Hey Keith,

Try this?

Cheers,

Mark

2 Likes

Thanks Mark!

First pass of testing seems to be fine.

I can see what you’ve done., but can you explain why the original code doesn’t work?

Cool,

So the original code was iterating through a list, that step wasn’t necessary.

It meant we got the value of i, where we just needed to use the existing value at position[first] and at position[last]

If that makes sense?

Cheers,

Mark

I don’t understand why it worked in some instances but not in others. Your amendment makes a lot more sense to me certainly but I’m trying to picture what’s happening with the iteration. Don’t worry though there’s lots of other bits I don’t get about this piece of code I don’t get either!! :rofl:

TBH I’d use nodes, if possible, you can see the process much easier & debug… or daisy chain a few pythons together?

I’m no expert so when I Python I use really basic inputs and OUT everything as I go…

I guess some of it worked because with less than 2 core items it skips down and uses the 2nd part which is set correctly.

Hope that helps,

Mark

1 Like

I started with basic nodes but couldn’t do what I needed which was when the python script came in. I’ll get there with it I just need to get back to by python basics course and stop trying to run before I can walk!! :slight_smile:

1 Like