Assign Materials to 4000 GH Objects

I have 4000 FBX format elements exported from Catia V5 or V6. Each element has a unique ID, 3D cooridnates and material properties.
I also have an “dynamic” Excel sheet with ID and time properties associates to each element, cause the time will change once a week.

My task is to

  1. put all elements in one Rhino model based on their coordinates.
  2. change elements’ material color according to color changes based on the predefined rules.
  3. outout the whole model as FBX.

I plan to get material name using Excel formula and output the then names to GH.

I want to know which GH components I should use to change the material colors.

Rhino Example is attached.
Materials.3dm (810.9 KB)

In this example, I want to assign “Concrete Purple”, “Concrete Green” and “Concrete Blue” to the 3rd, 4th and 5th object (from left to right), respectively in Grasshopper.
Result should be: 1

Update (it works, but see issue below):

  1. The baked geometries lose property, like the Name “A1”.
    Original A1
    1
    Baked A1
    2

  2. I want to write paramater and its value into “Attribute User Text” by GH, how to do that?

in order to control the visualization color of gh objects you can use the custom material component, under the display tab.
if you want you can fully control the color directly in GH using RGB, CMYK and HSV.
You can convert any data in number and use it as color.

to read the excel take a look at lunchbox on food4rhino.

Hi skysurfer

I couldn’t find “custom material component”, but I found “Creat Material” under GH->Display-> preview.
But it will generates material, how do I apply material to objects?

I’m sorry, I’m answering from the phone, so I don’t remember the right name of the component.
should be next to “create material”
Anyway, it’s kind of opposite behavior.
the object where displayed with specific material.
so
the geometry goes into the create material

here is one way to do it:

You can extract color or object information from any object and use this information to apply properties during bake. If you want a concrete color in there you would have to do some data matching, search the objects say you want concrete texture applied to, and then assign a bitmap texture to that specific branch during material creation. If you want the same texture to all materials then just give a file path in a flattened branch.

In the example i show, if you have multiple objects with the same color, you will get a material for that color only without doubling up.And the naming convention for mats will be just numerical…

Without doing this for you the level of difficulty will be intermediate, tell if you get stuck, i am sure someone may do the task for you…

but you will need at least in the def i have shown the plugins elefront - to get attributes and tree8 to create tree structure…

thanks, Arkadius

I think @skysurfer means the Custom Preview component. You can then easily reference your materials:

No need for third party plug-ins here, IMO.

@nathanletwory

they want objects with applied exportable materials not custom preview…

The materials used here are document materials, perfectly exportable.

Once everything is set up, just bake, and export.

ok, sure

i thought they needed color information, from objects…

but they would still need to sort the 4000 objects??!

The example 3dm contains the materials they want to assign. The Custom Preview component is the easiest to do so with the existing document materials.

I suggest adding a Custom Preview component for each color, then have logic that sorts the 4k objects such that each set connects to the correct preview component.

The logic is the rules by which decision of material is made, of course.

@nathanletwory

but they will need plugins to extract the excel data, no?

@netsonicyxf

the tricky bit will be sorting the data, anyhow. i can propose a method if the data embedded within the fbx geo as rgb layer color or other as this would make it easier than using excel sheets?

Thanks arkadius.belov for so many suggestions.

The color (or materials) will change according to other parameters which is stored in an Excel sheet.
It might be better to get the color (or the material name) in Excel based on those parameters then exportto GH to change objects color(material).

As for sorting the data, this is the excel example:

1
ID is the unique name assigned to each FBX object. P1-P3 is the parameters that change every week. Color values are determined from these parameters.

In grasshopper, the ID is not sorted in order (A1, A2, A3, A4, A5), instead it is sorted as below:


If I would use Dynamo (visual script tools for Autodesk), I can use “Dictionary” to find the corresponding values as below:

But I don’t know how to do it in GH.

in GH you can do it like this: (Key/Value Search Component)

EDIT:

There is also no big deal to sort your object by ID/Name,
just split the ID by ‘A’ and use the numbers for sorting

Great, thanks malo_m.

yes @netsonicyxf

I think you are on the right track, yes you can sort the objects using the key value search, and then bake / ref materials per id and object etc…!