def get_param_config(param_name, param_opts): # Extract parameter configurations from given dict # extract configured values param_bip_cat = coreutils.get_enum_value( DB.BuiltInParameterGroup, param_opts.get('category', DEFAULT_BIP_CATEGORY) ) param_type = coreutils.get_enum_value( DB.ParameterType, param_opts.get('type', DEFAULT_TYPE) ) param_isinst = param_opts.get('instance', 'false').lower() == 'true' param_formula = param_opts.get('formula', None) if not param_bip_cat: logger.critical( 'can not determine parameter category for %s', param_name ) return elif not param_type: logger.critical( 'can not determine parameter type', param_name ) return return ParamConfig( name=param_name, bicat=param_bip_cat, bitype=param_type, isinst=param_isinst, formula=param_formula )
def get_param_config(param_name, param_opts): # Extract parameter configurations from given dict # extract configured values param_bip_cat = coreutils.get_enum_value( DB.BuiltInParameterGroup, param_opts.get(PARAM_SECTION_GROUP, DEFAULT_BIP_CATEGORY) ) param_type = coreutils.get_enum_value( DB.ParameterType, param_opts.get(PARAM_SECTION_TYPE, DEFAULT_TYPE) ) param_famtype = None if param_type == DB.ParameterType.FamilyType: param_famtype = param_opts.get(PARAM_SECTION_CAT, None) if param_famtype: param_famtype = revit.query.get_category(param_famtype) param_isinst = \ param_opts.get(PARAM_SECTION_INST, 'false').lower() == 'true' param_isreport = \ param_opts.get(PARAM_SECTION_REPORT, 'false').lower() == 'true' param_formula = param_opts.get(PARAM_SECTION_FORMULA, None) param_default = param_opts.get(PARAM_SECTION_DEFAULT, None) if not param_bip_cat: logger.critical( 'can not determine parameter category for %s', param_name ) return elif not param_type: logger.critical( 'can not determine parameter type', param_name ) return # return a bundle with extracted values return ParamConfig( name=param_name, bigroup=param_bip_cat, bitype=param_type, famcat=param_famtype, isinst=param_isinst, isreport=param_isreport, formula=param_formula, default=param_default )
def read_csv_typed_data(csv_file): """Read Revit property data from the given CSV file.""" # open file with codecs.open(csv_file, 'rb', encoding='utf-8') as csvfile: # read lines csv_lines = list(csv.reader(csvfile, delimiter=',', quotechar='\"')) # grab the first line, extract field names # if field definition include the type, grab the associated # DB.ParameterType as well # https://www.apidocs.co/apps/revit/2019/f38d847e-207f-b59a-3bd6-ebea80d5be63.htm # https://support.spatialkey.com/providing-data-types-in-csv-headers/ field_defs = [] for field_def in csv_lines[0]: parts = field_def.split('|') parts_count = len(parts) if parts_count == 1: if parts[0]: field_defs.append((parts[0], DB.ParameterType.Text)) elif parts_count == 2: field_defs.append( (parts[0], coreutils.get_enum_value(DB.ParameterType, parts[1]))) # return field definitions, and data return (field_defs, csv_lines[1:])
def deserialize(self): return coreutils.get_enum_value(self.api_types, self.value)
forms.alert("Project has not been saved yet.", exitscript=True) elif destopt == "User Select": basefolder = forms.pick_folder() open_exported = switches["Open CSV File"] incl_headers = switches["Include Headers"] else: basefolder = forms.pick_folder() if basefolder: logger.debug(basefolder) schedules_to_export = forms.select_schedules() if schedules_to_export: vseop = DB.ViewScheduleExportOptions() if incl_headers: vseop.ColumnHeaders = coreutils.get_enum_value( DB.ExportColumnHeaders, "OneRow") else: vseop.ColumnHeaders = coreutils.get_enum_none( DB.ExportColumnHeaders) vseop.TextQualifier = DB.ExportTextQualifier.DoubleQuote # determine which separator to use csv_sp = ',' regional_sep = user_config.get_list_separator() if regional_sep != ',': if forms.alert("Regional settings list separator is \"{}\"\n" "Do you want to use this instead of comma?".format( regional_sep), yes=True, no=True): csv_sp = regional_sep