Families- Specific Type Loader by Excel ( Type Name)

I am trying to load specific Types of different family and I have excel data from advance steel - I have managed to get clean up the excel data and achieve ( Type Names - example SHS40x40x5 etc) now I want to load my company standard specific FamilySymbols ( Types) based on data sorted from advance steel.

I was able to duplicate preloaded type ( as each families has one type preloaded in the model) and change it type names based on excel data but steel members has Structural Section Geometry parameters and values which is specific for each type.

When we load families in Revit by Load family while choosing .rfa file we get a pop up of Type Catalog which let us select specific type(s).

We we get this option via Dynamo or python.

I did see a method in Revit API which let us load a specific type in the document but i am not able to map through it excel data.

Any help and suggestions would be really appreciated @c.poupin @jacob.small @sovitek @christian.stan or anyone

public bool LoadFamilySymbol(
	string filename,
	string name
)

Hi,

The Revit API does not allow you to load a family using a Type Catalog (txt file); you must load the family (which includes all types) and then delete any types you don’t want.

What does your Excel file look like?

1 Like

Hi @c.poupin, thanks for your insight - excel workbook look alike attchated

But I got it cleaned up and able to achieve
I got list full of 762 types - but manage to get Unique types

Are SHS180x6.3, SHS40x5 and SHS140x10 file names or type names? How are your RFA files organised?

It is Type name - family name is SteelSHS.rfa SteelRHS.rfa.

Type catalog is map with Txt file in the library so I used text file and mapped key words based on excel data - SHS, RHS etc and used Startwith to find correctly and then size 40x40x5 mapped with exactly with type catalog size.

only thing is to remove any preloaded family which types is required to be loaded - so it let override the txt file

Hi,
Here is an example with Python

import sys
import clr
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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


clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

import pandas as pd


xlsx_file_path = IN[0]
rfa_files_path = IN[1]

df = pd.read_excel(xlsx_file_path, usecols=range(1,7))
df = df.dropna(subset=["Size"])
# get unique types
types_names = df["Size"].unique()


symbolIds_loads = []
for file_path in  rfa_files_path:
    loadFamily = None
    TransactionManager.Instance.ForceCloseTransaction()
    TransactionManager.Instance.EnsureInTransaction(doc)
    result, loadFamily = doc.LoadFamily(file_path, loadFamily)
    TransactionManager.Instance.TransactionTaskDone()
    if result :
        symbolIds_loads.extend(list(loadFamily.GetFamilySymbolIds()))
        
# search types to delete (not in excel file)
deletIds = [xid for xid in symbolIds_loads if doc.GetElement(xid).Name not in types_names]
# search types to keep ( in excel file)
loadSymbols = [doc.GetElement(xid) for xid in symbolIds_loads if xid not in deletIds]
# delete unnecessary types
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Delete(List[ElementId](deletIds))
TransactionManager.Instance.TransactionTaskDone()
# last step is to delete Families with 0 types
# TODO

OUT = loadSymbols
2 Likes