# Get Family Type by Name Instead of Using Family Type Node

**URL:** <https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132>\
**Category:** Revit\
**Created:** [January 23, 2019, 10:32pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132 "2019-01-23T22:32:43Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [January 23, 2019, 10:32pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/1 "2019-01-23T22:32:43Z")

</div>

HI there, I am making a script that sorts amongst a lot of Family Types and chooses the adequated one based on the case. They annotate families that add details to my view and are placed automatically based on the sizes, etc.  
The problem is, every time the project is changed (Someone adds a Family for example) the index order of types change and it brakes the script, as the selected types changes as well.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/5/25fbc48d050980ef0f7a3efddcf2acabcc48a7e2.png)

So I am wondering how to retrieve these types by name since the name will remain the same.

I am sorry if this is basic, but I could not find how to by reading the search results on the Revit API and did not any post here with that subject.

Any help is appreciated, even the Revit API Method, etc.

Thanks!

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [January 23, 2019, 10:50pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/2 "2019-01-23T22:50:37Z")

</div>

See this post. Looks like Quasar package has a node that may help.

> [@Filter List By Family Type Name](https://forum.dynamobim.com/t/filter-list-by-family-type-name/25015):
>
> I have a routine to update room information from a linked model to Furniture in my current model. I can successfully filter my lists by parameter to get the exact furniture I want, but I can’t get figure out how to filter by Family Type Name. For example, if you load the out of the box desk family. It has three types, 60" x 30", 60" x 30" Student and 72" x 36". If all three types are placed in my model multiple times. How can I filter a list to only include the 60" x 30" family type. Thank you…

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [January 23, 2019, 10:52pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/3 "2019-01-23T22:52:27Z")

</div>

HI, Sean, thanks I will take a look!

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [January 24, 2019, 5:07pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/4 "2019-01-24T17:07:48Z")

</div>

I had a partial success with this script:

Figured it out with the help of @SeanP post and reading 🙂  
I checkd the Quasar package code, as well it lead me to:  
[http://www.revitapidocs.com/2018.1/b6d8bc8f-c63b-a3df-db37-cab501e503c1.htm](http://www.revitapidocs.com/2018.1/b6d8bc8f-c63b-a3df-db37-cab501e503c1.htm)  
[http://www.revitapidocs.com/2018.1/33042823-a11d-19d4-0d39-f1a4869284a3.htm](http://www.revitapidocs.com/2018.1/33042823-a11d-19d4-0d39-f1a4869284a3.htm)

from witch I figured what I needed to retrieve the Family Types.

```
import clr
clr.AddReference('RevitAPI') 
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI') 

 
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

import System
from System.Collections.Generic import *

# Place your code below this line
doc = doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

 
#Family symbol name to place.
symbName = 'Trail Shiplap Fill'
 
#create a filtered element collector set to Category OST_Mass and Class FamilySymbol 
collector = FilteredElementCollector(doc)
collector.OfCategory(BuiltInCategory.OST_GenericAnnotation)
collector.OfClass(FamilySymbol)
 
famtypeitr = collector.GetElementIterator()
#famtypeitr.Reset()
r=None
re=[]
#Search Family Symbols in document.
for item in famtypeitr:
	famtypeID = item
	
	if symbName in item.FamilyName:
		re.append([item.Family, item.Id, item.FamilyName])
    #If the FamilySymbol is the name we are looking for, create a new instance.
	
	
OUT = re  

```

I Probably imported more things that I needed but it worked off some sort.  
I can’t get the family type though.

If I set to return only the “item” variable it returns an object that contains the family type but I can’t convert it to string or anything.

Any toughts?

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [January 24, 2019, 5:20pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/5 "2019-01-24T17:20:40Z")

</div>

Hi,

I may not understand your problem, but why don’t you use the OOTB FamilyType.ByName node ?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/0/40f3aeafc4004f0a8a7233624b3769d06129729b.png)

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [January 24, 2019, 5:25pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/6 "2019-01-24T17:25:58Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/1/31a928c7551a8df3afea868dc7a8dd87444855f5.png)

Does not work for me.  
but with python:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/2/1259dd0cf6e41102721d0829be5a44f16416b48c.png)

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [January 24, 2019, 5:35pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/7 "2019-01-24T17:35:43Z")

</div>

I think you can do the same with OOTB Family.ByName and Family.types nodes.

 ![Family%20name](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/9/49e34bdab29aded1501863b92b6dd261f4f9bffa.png)

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [January 24, 2019, 5:45pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/8 "2019-01-24T17:45:45Z")

</div>

That one worked really good! Sorry for my ignorance. Had no idea!

---

<div class="post-metadata">

**Author:** ![truevis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/truevis/32/8634_2.png) [@truevis](https://forum.dynamobim.com/u/truevis)\
**Post date:** [May 8, 2019, 11:53pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/9 "2019-05-08T23:53:13Z")

</div>

How about?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/6/16bf651522c9191802819932a98b3a18ea626d38.png)

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [May 10, 2019, 2:30pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/10 "2019-05-10T14:30:02Z")

</div>

Hi, thanks for your input in this matter. It does look simpler.  
I will try it! Have a good weekend!

---

<div class="post-metadata">

**Author:** ![truevis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/truevis/32/8634_2.png) [@truevis](https://forum.dynamobim.com/u/truevis)\
**Post date:** [May 10, 2019, 10:23pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/11 "2019-05-10T22:23:27Z")

</div>

If using in Player with Inputs…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/9/c96523bc766d3768f47ee766695fd65f3299cec9.png)

---

<div class="post-metadata">

**Author:** ![baud.dem](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/baud.dem/32/171763_2.png) [@baud.dem](https://forum.dynamobim.com/u/baud.dem)\
**Post date:** [May 8, 2020, 10:59am UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/12 "2020-05-08T10:59:57Z")

</div>

Hello Guys,  
Sorry to wake up the topic a year after…  
I have a question directly linked to this topic.  
What if I want to select all the family loaded in the project as a list ? I know there is a node “Family Types” that gives a scrolling menu with them, but I would want them as a list. I would want to select them all automaticaly whitout creating a list one by one …  
Tell me if you have any clue !

Thank you so much

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [May 8, 2020, 11:20am UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/13 "2020-05-08T11:20:59Z")

</div>

Families or Family Types?

---

<div class="post-metadata">

**Author:** ![baud.dem](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/baud.dem/32/171763_2.png) [@baud.dem](https://forum.dynamobim.com/u/baud.dem)\
**Post date:** [May 8, 2020, 11:26am UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/14 "2020-05-08T11:26:16Z")

</div>

Family Types yes. To get a list of names of all the families that are loaded. (used or unused in the project)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [May 8, 2020, 12:21pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/15 "2020-05-08T12:21:44Z")

</div>

This python will give you families and family Types. You can remove the line for either the fams or famTypes if you don’t want one or the other.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/6/d63147012415dd8e0aba0a3c83044c29b1b374ef.png)

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

fams = FilteredElementCollector(doc).OfClass(Family).ToElements()
famTypes = FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements()

TransactionManager.Instance.TransactionTaskDone()

OUT = fams,famTypes
```

---

<div class="post-metadata">

**Author:** ![baud.dem](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/baud.dem/32/171763_2.png) [@baud.dem](https://forum.dynamobim.com/u/baud.dem)\
**Post date:** [May 12, 2020, 7:09am UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/16 "2020-05-12T07:09:39Z")

</div>

Thank you very much @SeanP

---

<div class="post-metadata">

**Author:** ![baud.dem](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/baud.dem/32/171763_2.png) [@baud.dem](https://forum.dynamobim.com/u/baud.dem)\
**Post date:** [May 12, 2020, 1:23pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/17 "2020-05-12T13:23:20Z")

</div>

@SeanP Would you also know how to do the same kind of things but with parameters. I am working on a family (.rfa), And to like to have access to its own parameters (names, values, formula). I have achieved to get the names, but I can’t get the value, I got “Null” each times.

> import clr
> 
> clr.AddReference(‘RevitAPI’)  
> from Autodesk.Revit.DB import \*  
> from Autodesk.Revit.DB.Structure import \*
> 
> clr.AddReference(‘RevitAPIUI’)  
> from Autodesk.Revit.UI import \*
> 
> clr.AddReference(‘System’)  
> from System.Collections.Generic import List
> 
> clr.AddReference(‘RevitNodes’)  
> import Revit  
> clr.ImportExtensions(Revit.GeometryConversion)  
> clr.ImportExtensions(Revit.Elements)
> 
> clr.AddReference(‘RevitServices’)  
> import RevitServices  
> from RevitServices.Persistence import DocumentManager  
> from RevitServices.Transactions import TransactionManager
> 
> doc = DocumentManager.Instance.CurrentDBDocument  
> uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
> 
> #Preparing input from dynamo to revit  
> element = UnwrapElement(IN[0])
> 
> #Do some action in a Transaction  
> TransactionManager.Instance.EnsureInTransaction(doc)
> 
> fams = FilteredElementCollector(doc).OfClass(Family).ToElements()  
> famTypes = FilteredElementCollector(doc).OfClass(FamilySymbol).ToElements()
> 
> param= doc.FamilyManager.GetParameters()
> 
> pNames= #list of names of parameters  
> pS= #similar to param if all parameters are selected, but can be less, depending on the list of names we want
> 
> for p in param:  
> n=p.Definition.Name  
> pNames.append(n)  
> pS.append(doc.FamilyManager.get\_Parameter(n))
> 
> types = doc.FamilyManager.Types #types of the family  
> famMan = doc.FamilyManager  
> categ=doc.OwnerFamily.FamilyCategory.Name #family category
> 
> #family TYPES  
> #add “Default” type in families with no types  
> familytypecount =   
> familytypecount.append(types.Size)  
> if familytypecount \< 1:  
> TransactionManager.Instance.EnsureInTransaction(doc)  
> new\_fam=famMan.NewType(‘Default’)  
> TransactionManager.Instance.ForceCloseTransaction()
> 
> #get assembly code from types
> 
> familyTypesItor = famMan.Types.ForwardIterator()  
> familyTypesItor.Reset()
> 
> param\_values=
> 
> while(familyTypesItor.MoveNext()):  
> #getcurrentvalue  
> for n in pNames:  
> familyParam = famMan.get\_Parameter(n)  
> familyType = familyTypesItor.Current  
> \>param\_values.append(familyType.AsString(familyParam))
> 
> #TransactionManager.Instance.TransactionTaskDone()  
> TransactionManager.Instance.ForceCloseTransaction()  
> OUT = fams,famTypes,pNames,param\_values,familytypecount

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [May 12, 2020, 2:06pm UTC](https://forum.dynamobim.com/t/get-family-type-by-name-instead-of-using-family-type-node/31132/18 "2020-05-12T14:06:53Z")

</div>

Check this revised Python for Family parameters. This is a good start, but isn’t going to cover everything you’ll probably need.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c89cf898cb369f733448a40e031f8b7b0b35c11e.png)

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

run = IN[0]

#Do some action in a Transaction
famTypes = []
pNames = []
pValue = []

types = doc.FamilyManager.Types
params = doc.FamilyManager.Parameters

if run:
	TransactionManager.Instance.EnsureInTransaction(doc)
	for param in params:
		pNames.Add(param.Definition.Name)
	
	for type in types:
		famTypes.Add(type)
		for param in params:
			StoreType = param.StorageType
			if StoreType == StorageType.Double:
				v = type.AsDouble(param)
			elif StoreType == StorageType.Integer:
				v = type.AsInteger(param)
			elif StoreType == StorageType.String:
				v = type.AsString(param)
			elif StoreType == StorageType.ElementId:
				v = type.AsElementId(param)
			
			pValue.Add(v)
	TransactionManager.Instance.TransactionTaskDone()
	OUT = famTypes,pNames,pValue
else:
	OUT = "Set Run to True"
```
