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
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
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:
TransactionManager.Instance.EnsureInTransaction(doc)
try:
for name in names:
doc.FamilyManager.NewType(name)
log = 'NewType created successfully'
except:
log = 'An error occurred! Please verify setting'
TransactionManager.Instance.ForceCloseTransaction()
#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