Create New Family Types in Family Document while in Project Environment

I realized that I could not find a solution on the forum or any packages (that I already had) that allows adding a new family type to a family document while in a project file, after seeing this post here and searching:

There are already shared workflows/nodes that allow users to create new family types within the project environment, but I couldn’t find any that would save those new family types within the family documents themselves, as well.

Given the API docs show that the Family Manager has a NewType method, I went ahead and tried making a Python script that could achieve just that, utilizing code written by @erfajo from the DanEDU Dynamo package nodes.

It works perfectly for me, so figured I should post here since I could not find other shared methods! (notes in image above indicate source packages for non-OOTB nodes)

Here is the Python code:

import clr
from Autodesk.Revit.DB import*

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#input assigned the IN variable
docs = IN[0]
names = IN[1]

#wrap input inside a list (if not a list)
if not isinstance(docs, list): docs = [docs]
if not isinstance(names, list): names = [names]

#default document set to DocumentManager.Instance.CurrentDBDocument
if docs[0] == 'Current.Document':
	docs = [DocumentManager.Instance.CurrentDBDocument]
else: pass

#core data processing
for doc in docs:
		for name in names:
			log = 'NewType created successfully'
		log = 'An error occurred! Please verify setting'

#output assigned the OUT variable
OUT = docs, log

Many thanks to @erfajo and his family document nodes, because this code was made by editing just a few lines from the node DanEDU.FamilyDocument.SetFormulaByName

Hope this will be of use to others :slight_smile:


thanks @awilliams :slight_smile:

To those who are interested… it is not that difficult to do even more with families, just try to implement other methods from the API


Hi Amy,

Great addition to the (also great) nodes of the DanEDU package :thumbsup:
What i like about this workflow is that it’s modular.
In this way you can easily create a lot of DynamoPlayer scripts (for repeating/boring tasks).
Just pick the node you need, and pass the FamilyDocuments on to the next in line.
Thanks again.

Kind regards,

1 Like

Thanks for sharing Amy, helped me a lot!:grinning: