from MF_GetFilterRules import * from MF_CustomForms import * from MF_MultiMapParameters import * from MF_ExcelOutput import * filters = FilteredElementCollector(doc).OfClass(ParameterFilterElement) allViews = FilteredElementCollector(doc).OfClass(View).ToElements() viewTemplates = [] allBuiltInCategories = Enum.GetValues(clr.GetClrType(BuiltInCategory)) allCategories = [i for i in doc.Settings.Categories] modelCategories = [] modelCategoryNames = [] time = strftime("%Y-%m-%d %H:%M:%S", localtime()) projectInfo = [["Project File: ", doc.Title], ["Path", doc.PathName], ["Export Date:", time]] for c in allCategories: #c = doc.GetCategory( bic)
def enum_generator(): for enum_member in Enum.GetValues(Enum): yield enum_member # type: Enum
import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import BuiltInParameter from System import Enum key = 'FAMILY_HOSTING_BEHAVIOR' names = Enum.GetNames(BuiltInParameter) values = Enum.GetValues(BuiltInParameter) bip_dict = dict(zip(names, values)) # Returns a BuiltInParameter given its name (key) bip = bip_dict[key] # For above solution # See: https://forum.dynamobim.com/t/setting-built-in-parameter-by-using-a-variable-value/49466 # Get the Plumbing Fixtures from the model. pfs = (FilteredElementCollector(doc) .OfCategory(BuiltInCategory.OST_PlumbingFixtures) .WhereElementIsNotElementType() .ToList() ) # Loop through them and check the BuiltInParameter for Hosting Behaviour # Looking for Floor Hosted families only i = 0 for pf in pfs: i += 1
############################## def group(seq, sep): g = [] for el in seq: if el == sep: yield g g = [] g.append(el) yield g time = strftime("%Y-%m-%d %H:%M:%S", localtime()) bics = Enum.GetValues(clr.GetClrType(BuiltInCategory)) bicats = [] for bic in bics: try: if doc.Settings.Categories.get_Item(bic): c = doc.Settings.Categories.get_Item(bic) bicats.append(c) #catIDs.append(c.Id) realCat = Category.GetCategory(doc, bic) bicats.append("realCat" + str(realCat)) except Exception as e: bicats.append(str(e)) pass
def pull_data(sol_cxn, time_res, args, arg_opt, default_csv): from EEUTILITY.Enums import SimulationPhaseEnum, CollectionEnum, PeriodEnum, ClassEnum # is this time_res active? If not quit if not is_switch(args, arg_opt): return # date_from and date_to date_from = switch_data_to_date(args, '-f') date_to = switch_data_to_date(args, '-t') start_time = time.time() # start timer # get the csv_file name csv_file = switch_data(args, arg_opt) if csv_file is None: csv_file = re.sub('\.zip$', '', args[1]) + default_csv # remove the csv_file if it already exists if os.path.exists(csv_file): os.remove(csv_file) # loop through all relevant collections and phases config_json = switch_data(args, '-c') if not config_json is None and os.path.exists(config_json): cfg_json_obj = json.load(open(config_json)) for query in cfg_json_obj['queries']: try: phase = Enum.Parse(SimulationPhaseEnum, query['phase']) coll = sol_cxn.CollectionName2Id(query['parentclass'], query['childclass'], query['collection']) except: print("Phase:", query['phase'], "Collection:", query['collection'], "Parent Class:", query['parentclass'], "Child Class:", query['childclass']) print(" --> This combination doesn't identify queryable information") continue # If the phase or collection are missing or incorrect just skip if 'properties' in query: # the data in properties field may be a list of property names; we'll pull each individually if type(query['properties']) is list: for prop in query['properties']: try: prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], prop)) query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id) except: pass # the data in properties field may be a single property name; we'll just pull it elif type(query['properties']) is str: try: prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], query['properties'])) query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id) except: pass # the data in properties field may be poorly formatted else: print(query['properties'],'is not valid property information') # properties field may be missing; just pull all properties else: query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v')) else: for phase in Enum.GetValues(clr.GetClrType(SimulationPhaseEnum)): for coll in Enum.GetValues(clr.GetClrType(CollectionEnum)): query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v')) print('Completed',clr.GetClrType(PeriodEnum).GetEnumName(time_res),'in',time.time() - start_time,'sec')