Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66705

Re: Getting Materials used by Instances in the project?

$
0
0

Hey Mendo, 

 

I've just done this exact thing in one of my macro's, and i saw this post. 

So here's how i do it: 

 

i have a collection.OfClass( FamilyInstance ) 

i have a matList[]

i have a matNameList[]

 

then i loop through the project

for f in collection:

    paraMaterial = f.Symbol.get_Parameter( BuiltInParameter.STRUCTURAL_MATERIAL_PARAM ) 

    material = doc.GetElement( paraMaterial.AsElementId() ) 

    if material != None:

        if material.Name not in matNameList: 

            matNameList.Add( material.Name ) 

            matList.Add( material ) 

 

after going through this loop your matList[] contains all the materials used in the project (only one instance of every material)

 

if you want to assign a material you can use this format: 

 

paraMaterial.Set( material.Id ) # paraMaterial contains your familyInstance reference, and material can be an item in your list. 

 

Hope this helps you ;) 

 


Viewing all articles
Browse latest Browse all 66705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>