Hi, guys! First of all, let me start with the fact that I am new to writing code in Python and working with the Revit API. In this case, I tried to create a code that takes the strings from family and type names for all family instances of certain categories and then copies them to text shared text parameters, that can be used in schedules. I am using the Revit Python shell to run the script. As you will see, I have divided the code in two sections - the second one is for the system family categories, like walls, floors, roofs, etc, that only need Type names to bo transfered, while the first is for all other categories, that need both family and type name transfered. The problem is the it all seems to work fine, but for some of the categories it simply does not give results. For instance, I do not realise why it works for walls, but not for floors, and it also does work for ceilings and not for roofs, etc. Could you please help me find what the problem is? Thanks in advance! Here is the code(also available as attatchment):
__title__= 'FamilyName\nTypeName'
__doc__= 'Transfers family name and Type name into shared parameters\n that can be used in schedules.'
__author__= 'Dani & Bimo'
# Import from Autodesk API
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory
doc = __revit__.ActiveUIDocument.Document
element_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()
element_filter = ElementCategoryFilter(BuiltInCategory.OST_PlumbingFixtures.OST_Casework.OST_Columns.OST_Windows.OST_Furniture)
category = element_collector.WherePasses(element_filter).ToElements()
t = Transaction(doc, "Update Family/Type Name")
t.Start()
for instance in category:
TypeName = instance.Name
TypeNameDuplicate = instance.LookupParameter('TypeNameDuplicate')
if TypeNameDuplicate:
TypeNameDuplicate.Set(TypeName)
for i in category:
type_id = i.GetTypeId()
element_type = doc.GetElement(type_id)
family = element_type.Family
name = family.Name
FamilyNameDuplicate = i.LookupParameter('FamilyNameDuplicate')
if FamilyNameDuplicate:
FamilyNameDuplicate.Set(name)
t.Commit()
system_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()
system_filter = ElementCategoryFilter(BuiltInCategory.OST_Walls.OST_Ceilings.OST_Curtain_Systems.OST_CurtainWallMullions.OST_Floors.OST_ModelText.OST_Railings.OST_Roofs.OST_Stairs)
system_category = system_collector.WherePasses(system_filter).ToElements()
t.Start()
for system_instance in system_category:
SystemTypeName = system_instance.Name
TypeNameDuplicate = system_instance.LookupParameter('TypeNameDuplicate')
if TypeNameDuplicate:
TypeNameDuplicate.Set(SystemTypeName)
t.Commit()