Create material from the excel file

MATERIALS-Create-from-Excel_MH.dyn (21.1 KB)

Hello all,

I am trying to use excel as a material database as we use various software etc so I need a central resource. I want to use Dynamo to add these materials to Revit, and be able to update them. Unfortunately the out of the box nodes are not sufficient so I am trying to use python as well. I am however getting tripped up in one of the first steps.

I can add materials to Revit, but if the script is re run or a materials is added to the list, it will not run as there is already a materia with that name present. Help appreciated!

This is the script

import clr
clr.AddReference(ā€œRevitAPIā€)
from Autodesk.Revit.DB import *
clr.AddReference(ā€œRevitServicesā€)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

names = IN[0]

newMaterials =
for mat_name in names:
TransactionManager.Instance.EnsureInTransaction(doc)
new_mat_id = Material.Create(doc, mat_name)
new_mat = doc.GetElement(new_mat_id)
TransactionManager.Instance.TransactionTaskDone()
newMaterials.append(new_mat)

OUT = newMaterialsRevit Dynamo test1.xlsx (18.9 KB)

Hi @minho3.jung,

There are already packages with custom nodes to create and edit materials like for example Genius Loci package.

1 Like

thanks for advoice where can i find Genius Loci package? do you know homapage or wepsite?
if you know some infomation plz reply! or send some massage thanks!

To install a package you have two options :

2 Likes

thank for reply!

Thanks For make amazing dynamo package!

But when I use genius loci Create material node is not work ā€¦
Please let me know why not working the create material node and whatā€™s wrong.
use verstion : revit 2018 & dynamo 2.0.3.0
Create Material From Excel_Dynamo.dyn (29.2 KB) dynamo-now-MATERIALS-Create-from-Excel.xlsx (40.2 KB)

Hi Jung,

Iā€™m glad you find the package useful.

The custom node use colors and not a list of integers.
Your graph :

Working graph :


Create Material From Excel_Dynamo V2.dyn (27.8 KB)

4 Likes

Really Thanks Reply.
this dynamo really help my work .

Does anyone have a workflow for this in Revit 2021? Iā€™m trying to follow the steps above but am having no luck creating the materials.

1 Like

Should be the same workflow in revit 2021. What issue are u facing

Roddy, I expect you are having a similar issue to I am having.

If I load the latest package I only get one result from the list. I found that if I load a package from December 2019 it will create a list of new materials based on the excel file above.

But all the fill materials and colours are default empty. I suspect it is associated with the error. I get about loading the \Dynamo Revit\2.6\packages\Genius Loci\bin\itextsharp.dll

Failed to load library ā€¦ Dynamo\Dynamo Revit\2.6\packages\Genius Loci\bin\itextsharp.dll

At least I can create the materials. I can probably assign colours and patterns separately.

If you use the latest package you do not get the error but it only creates 1 item form the list (the first) but it does colour it in.

One other think you need to close the material pallet in Revit for it to create the materials. It does not seem to over write existing materials either. This is probably a good thing in retrospect.

If I find a work around I will upload.

Hi,

Welcome to the Dynamo forum.

If you take a closer look at the solution image, youā€™ll see that you need to set the lacing to longest (right-click on the Create Material node).
Itā€™s rarely a good idea to use versions that are more than 3 years old. The latest update of the Genius Loci package should do the trick with proper lacing.

https://primer.dynamobim.org/06_Designing-with-Lists/6-1_whats-a-list.html

Alban

Thanks, I missed that one. I wish I had asked earlier. it would have saved a lot of time going no where.

I did not pick up when I swapped in newer node in the new version that I lost the original lacing.

Now this has been adjusted it now seems to be working.

Thanks for your help.

Frank Crichton

1 Like

The script is cool wapshe bomb!

How to add data to parameters for example: key note, description, URL, material type, hatching, filling and fill in other parameters for these materials?

I look forward to your reply, thank you

Hi,

Look at the Genius Loci package.There are plenty of useful nodes for editing materials.

Iā€™m still new to Dynamo, can you help me at least understand how to set a parameter to a material from a column in an excel file?

Go and spend some time with Dynamo Primer, donā€™t just begin learning without reading the guides.

Excel is a similar data structure to this part:
https://primer.dynamobim.org/06_Designing-with-Lists/6-3_lists-of-lists.html

You have begun with a very difficult topic in Dynamo, Iā€™d suggest working your way towards it by solving it in small steps, sharing your progress with the forums when you get stuck (do not just ā€˜get stuckā€™ immediately, actually have a good attempt) then you will likely get more help.

A good programmer will need to learn to search and research before asking for answers.