Check for Duplicate Material Names

Hi,

I’d like to propose a ‘quality-of-life’ improvement:

A colleague recent got bit by this unexpected behavior, and was quite confused until we tracked down the issue:

If you have more than one material with the same name, only one of those materials survives model serialization/de-serialization. For instance: with two ‘INSULATION’ layers, with different thicknesses:

only one of those materials makes it through the serialization round-trip:


I understand the simple solution is for all EnergyMaterials to have unique names, and so my suggestion is to build in a check/user-display-warning at some point along the chain that gives some clear warning to the user that they have done this (duplication of names), that this issue will pop up during model serialization, and that the fix is to provide unique names.

This check could occur at any number of components (Construction, Construction-Set, Room, Model,…) but I would think that this check would be best done at the ‘serialization’ stage (ie: model.to_dict()) since there is where the model would have the complete view of all materials in the project?

best,
@edpmay


Sample GH File:

material_test.gh (32.7 KB)

5 Likes

Hey @edpmay ,

I have plans to address this eventually by throwing an error during serialization but, for now, the easiest way to identify these cases is to run the Model through the HB Validate Model component before you write it out to HBJSON. There’s a check that runs in the validation process that will identify and report the duplicates material identifier (as well as any other duplicated IDs).

2 Likes

That’s a good solution for sure. I’ll recommend we add that component to our standard workflow in the future.

FYI: I also added an Issue with another possible solution.

best,
@edpmay

1 Like