Creating a Loop to replace parameter values

Hi all,

I have a parameter that has been made up of 3 values which I’m now trying to split into 3 separate parameters. Most elements have an ST14 and ST13 and they are easy dealt with. However the remaining value varies from ST01 to ST25. Is there a way I can create a Loop for the other values so that Dynamo check for 01, 02 etc excludes 13 and 14 and then continues up to 25?

I know i can repeat the script I have for specific values but it feels very clumsy and I’m keen to learn a better way.

Cheers

K.

Try and see if this works: (I’m not sure ;))

Edit: It will only work if you one element of each parameter. I think RegEx would work:

Hi Einar, thanks for looking at this. That sorta works… but the flattened list doesn’t tally with the original list as some values are Empty from the RegEx node - so the data is getting written to the wrong families…

Are they returned as null? You could try to replace nulls before you flatten.

They are returned as ‘empty list’… not sure if that is technically the same thing or not?

Well, they are both “nothing”. If you transpose the list, the empty lists vil turn into nulls.

Clockwork has a ReplaceEmptyList node:

See if this makes sense…
dict.dyn (2.5 KB)

1 Like

Thanks Vikram,

I can see what it’s doing but I don’t quite understand the code.

In my scenario I have a parameter that might look like this “ST01,ST14,ST13” so that field would need to populate SignageOther with ST01, SignageFM with ST14 and SignageFire with ST13.

If I run the code you have shown on my list it just gives me a value when the source parameter only contains one matching value… is there another step I need?

@Keith_Wilkinson1
I seem to have misunderstood your intent
Help me understand, Do the following statements correctly capture your intent?
-You have doors that already have a parameter that is SignageOther or SignageFM or SignageFire
-Doors with parameter SignageFire need to be assigned another parameter ST13
-Doors with parameter SignageFM need to be assigned another parameter ST14
-Other doors need be be assigned parameters ST0 to STn (except no.s 13 & 14)

I have a parameter currently called ‘SignageTypes’ that has multiple values. I’m trying to split the multiple values across 3 new parameters Other, Fire and FM. So for instance the value in SignageTypes of "ST01,ST13,ST14’ would be split as SignageOther - ST01, SignageFM - ST13 and SignageFire - ST14.

The combinations vary from door to door so some will only have ST13 for example. Does that make sense?

Like this then?

Please share a sample Revit and Dynamo file

Would require specifics, the above statement is too vague

Now that is very close and I can see how that works. The only problem is the person that input the values didn’t do so in order, i.e. ST14 doesn’t always come at the end.

As per Vikram’s request I’ll upload a couple of files.

HI,

In this post http://bimtroublemaker.blogspot.nl/2014/09/practical-dynamo-excel-linking.html you can see the value of using Unique ID to write to the correct families. You could try doing youre magic work in excel and then linking it back in.

Marcel

Sorry, file size a little restrictive had to make an example from scratch but here you go. Essentially I’m trying to tidy up the mess at bottom right of the dyn file with a single loop.

0.9.2-SignageTypes-0.0.2.dyn (106.1 KB)
Doors.rvt (1.7 MB)

You’ve explained above what happens when the parameter has three values.
But what happens when it has one or two?
For example:

  • If there is one value does that one value get assigned yo all three?
  • In the case of two values which two parameter do you assign it to?

No, ST13 and ST14 are unique and will apply specifically to the Fire and FM parameters. There will only be one other value in the SignageTypes parameter that will be assigned to the Other parameter. So for example you wouldn’t have “ST05, ST06, ST14” as a combination.

That makes thinks clearer.

1 Like

This may not be easy to understand, but should do the job …
SplitAndAssignParameterValue.dyn (18.7 KB)

Here is my alternative with RegEx and an Imperative codeblock:


splitParameter.DYN (6.2 KB)

chooseParamName(val);

def chooseParamName(value) {
	return = [Imperative]
	{
		if(value == "ST13"){
			return = "SignageFM";
		}
		elseif(value == "ST14"){
			return = "SignageFire";
		}
		else{
			return = "SignageOther";
		}
	};
};
3 Likes