def exportschedule(): # ViewScheduleExportOptions options = DB.ViewScheduleExportOptions() options.Title = False folderpath = filepath("filepath.txt") sched_list = selectschedule() if sched_list: for i in sched_list: filenamestr = i.Name + ".csv" i.Export(folderpath, filenamestr, options) #print i.Name, "exported to" , folderpath , filenamestr else: sys.exit()
def exportschedule(): # ViewScheduleExportOptions options = DB.ViewScheduleExportOptions() options.Title = False # no Title in first line of csv file mess = [] folderpath = filepath("filepath.txt") sched_list = selectschedule() if sched_list: for i in sched_list: filenamestr = i.Name + ".csv" export = i.Export(folderpath, filenamestr, options) mess.append(filenamestr) #print i.Name, "exported to" , folderpath , filenamestr return mess else: sys.exit()
def exportschedule(): # ViewScheduleExportOptions options = DB.ViewScheduleExportOptions() options.Title = False folderpath = filepath("filepath.txt") sched_list = selectschedule() list = [] print "sched_list: ", len(sched_list) if sched_list: for i in sched_list: filenamestr = i.Name + ".csv" list.append(filenamestr) i.Export(folderpath, filenamestr, options) out = "{} --> exported".format(filenamestr) print(out) #print i.Name, "exported to" , folderpath , filenamestr return (folderpath, list) else: sys.exit()
def main(): """Main script docstring.""" print("🐍 Running {fname} version {ver}...".format(fname=__name, ver=__version)) # STEP 0: Setup app = __revit__.Application doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument view = doc.ActiveView # STEP 1: Find all appropriate schedules print("Getting all available schedules from the model...", end="") all_schedules = db.FilteredElementCollector(doc)\ .OfCategory(db.BuiltInCategory.OST_Schedules)\ .WhereElementIsNotElementType()\ .ToElements() print("✔") print(" ➜ Found {num} schedules in the project.".format( num=len(all_schedules))) #print(all_schedules) # STEP 2: Filtering for quantification schedules (with given prefix) print("Filtering quantification schedules from the found schedules...", end="") quantity_schedules = [ s for s in all_schedules if s.Name.startswith(PREFIX) ] print("✔") print(" ➜ Found {num} schedules with prefix '{prefix}'.".format( num=len(quantity_schedules), prefix=PREFIX)) #print(quantity_schedules) # STEP 3: Ask for export folder location print("Please select an output folder for saving the schedules...", end="") folder_browser = swf.FolderBrowserDialog() folder_browser.Description = "Please select an output folder for saving the schedules." if folder_browser.ShowDialog( ) != swf.DialogResult.OK: # no folder selected print("\n✘ No folder selected. Nothing to do.") return ui.Result.Cancelled print("✔") print("🛈 Selected output folder: {folder}".format( folder=folder_browser.SelectedPath)) # STEP 3: Export all selected schedules # https://www.revitapidocs.com/2018/8ba18e73-6daf-81b6-d15b-e4aa90bc8c22.htm print("Exporting schedules as CSV to selected output folder...", end="") try: export_options = db.ViewScheduleExportOptions() export_options.FieldDelimiter = "," for schedule in quantity_schedules: file_name = "{name}.csv".format(name=schedule.Name) schedule.Export(folder_browser.SelectedPath, file_name, export_options) except Exception as ex: print("\n✘ Exception:\n {ex}".format(ex=ex)) return ui.Result.Failed else: print("✔\nDone. 😊") return ui.Result.Succeeded