To add to this I can see forgetypeIds are going to be on my radar so I bit the bullet and figured out how to get specs/groups by name. Much easier than I thought, I quite like them now vs the old method - targeting the human friendly name is great.
# Boilerplate text
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument
# Preparing input from dynamo to revit
specs_get = IN[0]
groups_get = IN[1]
# Get forgetypeids and names
spec_ids = SpecUtils.GetAllSpecs()
spec_names = [LabelUtils.GetLabelForSpec(s) for s in spec_ids]
# Get grouptypeIds and names
group_ids = ParameterUtils.GetAllBuiltInGroups()
group_names = [LabelUtils.GetLabelForGroup(g) for g in group_ids]
# Function: Return element by name match
def element_byNameMatch(n, elements, names):
if n in names:
ind = names.index(n)
return elements[ind]
else:
return None
# Return forgetypeIds
OUT = [ [element_byNameMatch(n, spec_ids, spec_names) for n in specs_get],\
[element_byNameMatch(n, group_ids, group_names) for n in groups_get] ]
Get forgetypes by name.dyn (6.4 KB)