Fill Conduit Parameter by Conduits in Run

I am trying to create a script which will allow a user to fill in conduit parameters based on the conduit run (basically a network of conduits). The ‘wrench’ in the query is that the parameter I am trying to fill, will be populated through Revit and may occasionally contain multiple values.

I need to review the conduit runs then for conduits within the run that have different values in (in this case) their Cars Tag parameter and ideally highlight these runs which may contain an error - OR - if the conduits in the run only have one parameter (applied to only one conduit or many) I need that parameter populated to the remaining conduits in the run.

GroupConduitRuns.ApplyParameterbyRun.dyn (40.6 KB)

I think I have gotten pretty close but an struggling with the IF statement. I know I have it in the wrong sequence since both the TRUE and FALSE are running.

Help!
Thanks for all your help in advance :slight_smile:

First: When checking for possible errors in a run, you’re probably better off with a filter than an If statement. Get the parameter value for all conduit in the run and use GroupByKey to group the elements based on their parameter value. Count the elements in each group. The group with the most elements (most common parameter value) is likely to be the correct value. Use this value to filter your groups - those with the most common value are “good” and the rest are “bad”. You can then highlight all the elements in the “bad” groups.

Second: Once you have the first part working you can add a little If statement to check for conduit without an assigned value. Simply filter those elements out again and set the parameter value equal to the “good” value from the previous check.

Hi @Nick_Boyts - Would you be able to elaborate with some graphics?

I’ll be honest I’ve been staring at this one all day and am having trouble following the logic at this point.

Also just a quick note I do actually start with some filters - the snapshot I was showing was just the last portion of the script. Of course if there are better ways of working I would appreciate all suggestions!

Thanks for your help!

We’re making the assumption that most of the conduit in a run are going to have the correct value, so we’re checking for the value that shows up the most. Then we can split our list of elements into those that have the correct value and those that don’t.
image

You can use a similar approach to filter out the elements that have no value assigned to them and set that parameter using our correct value.

Thanks for the visual @Nick_Boyts
It works!