Join Objects by Material

Hi there,
can someone give me a hint on how to iterate trough the geometry and join objects by their Material?

I am quite new to scripting in Rhino, and the difference between RhinoCommon, and python rhinoscriptsyntax and rhinoscript confuses me a lot…
somehow I was still able to make a little script that joins objects by Layer-
which is already quite helpful- (by using " rs.ObjectsByLayer ")
but I would like to have a script that selects/joins by material as well.
Could someone push me in the right direction?

you can use SelMaterialName and then Join?

Idk about scripting, but I use SelMaterialName all the time to join and create groups to export to 34d party renderers

Yes- that funtionallity is basically what I want, but I didn´t find anything like it in the - API.
Thats why I am askin- sur there is a way of doing this automated in a script-
but i wasn´t able to figure out how so far…

You can create your own button with a few commands in it. More on macros here

So for example:


…or whatever command you need…

That sound interesting, but is not what i am after -
I want to loop through a hole (complex and big) File, and with a Macro it would be only an Semi-automated process…

I am sure Rhinocommon has what I need- I just dont know where to look for it…
-“ObjectsByLayer” Function works great-
I would have expected a “ObjectsByMaterial” Function, but there is none… (At least not in the documentation)
“ObjectByColor” Function doesn´t seem to do the trick… is Color a different attribute in rhino?
or are Color and Material the same?