def load_session(): """Handles loading/reloading of the pyRevit addin and extensions. To create a proper ui, pyRevit extensions needs to be properly parsed and a dll assembly needs to be created. This function handles these tasks through interactions with .extensions, .loader.asmmaker, and .loader.uimaker Example: >>> from pyrevit.loader.sessionmgr import load_session >>> load_session() # start loading a new pyRevit session Returns: None """ # initialize timer to measure load time timer = Timer() # perform pre-load tasks _perform_onsessionload_ops() # create a new session _new_session() # perform post-load tasks _perform_onsessionloadcomplete_ops() # log load time and thumbs-up :) endtime = timer.get_time() success_emoji = ':ok_hand_sign:' if endtime < 3.00 else ':thumbs_up:' logger.info('Load time: {} seconds {}'.format(endtime, success_emoji))
def load_session(): """Handles loading/reloading of the pyRevit addin and extensions. To create a proper ui, pyRevit extensions needs to be properly parsed and a dll assembly needs to be created. This function handles these tasks through interactions with .extensions, .loader.asmmaker, and .loader.uimaker Example: >>> from pyrevit.loader.sessionmgr import load_session >>> load_session() # start loading a new pyRevit session Returns: None """ # setup runtime environment variables sessioninfo.setup_runtime_vars() # the loader dll addon, does not create an output window # if an output window is not provided, create one if EXEC_PARAMS.first_load: output_window = _setup_output() else: from pyrevit import script output_window = script.get_output() # initialize timer to measure load time timer = Timer() # perform pre-load tasks _perform_onsessionloadstart_ops() # create a new session _new_session() # perform post-load tasks _perform_onsessionloadcomplete_ops() # log load time and thumbs-up :) endtime = timer.get_time() success_emoji = ':OK_hand:' if endtime < 3.00 else ':thumbs_up:' mlogger.info('Load time: %s seconds %s', endtime, success_emoji) # if everything went well, self destruct try: timeout = user_config.startuplog_timeout if timeout > 0 and not logger.loggers_have_errors(): if EXEC_PARAMS.first_load: # output_window is of type ScriptConsole output_window.SelfDestructTimer(timeout) else: # output_window is of type PyRevitOutputWindow output_window.self_destruct(timeout) except Exception as imp_err: mlogger.error('Error setting up self_destruct on output window | %s', imp_err) _cleanup_output() return sessioninfo.get_session_uuid()
def load_session(): """Handles loading/reloading of the pyRevit addin and extensions. To create a proper ui, pyRevit extensions needs to be properly parsed and a dll assembly needs to be created. This function handles these tasks through interactions with .extensions, .loader.asmmaker, and .loader.uimaker Example: >>> from pyrevit.loader.sessionmgr import load_session >>> load_session() # start loading a new pyRevit session Returns: None """ # initialize timer to measure load time timer = Timer() # perform pre-load tasks _perform_onsessionload_ops() # create a new session _new_session() # perform post-load tasks _perform_onsessionloadcomplete_ops() # log load time and thumbs-up :) endtime = timer.get_time() success_emoji = ':ok_hand_sign:' if endtime < 3.00 else ':thumbs_up:' logger.info('Load time: {} seconds {}'.format(endtime, success_emoji)) # if everything went well, self destruct try: from pyrevit.coreutils.console.output import output_window timeout = user_config.core.startuplogtimeout if timeout > 0 and not logger_has_errors(): output_window.self_destruct(timeout) except Exception as imp_err: logger.error( 'Error setting up self_destruct on output window | {}'.format( imp_err))
# if ind_nops: # for i in reversed(ind_nops): # viewlist.pop(i) # filepathlist.pop(i) for v, fp, ps in zip(viewlist, filepathlist, papersizeobjls): print(v.Name, fp, ps.Name) #---INPUT---------------------------------------- pdfprinterName = "PDFCreator" combined = True #default, since 1 sheet per print function print("\n LoopPrint, printer: {} -----------------------------".format(pdfprinterName)) # Print List of views ------------------------------------------- try: if isinstance(viewlist, list): for v, fp, ps in zip(viewlist, filepathlist, papersizeobjls): pview = printview(doc, v, fp ,ps ,pdfprinterName, combined ,tmp_printsetting) print(pview) else: print "Error: viewlist not exist " except: # if error accurs anywhere in the process catch it errorReport = traceback.format_exc() print(errorReport) endtime = timer.get_time() print(endtime) # ------------
# RESTA LA VENTANA ENTERA DE DONDE TENGA EL RCP, Y DEL MURO DONDE ESTÉ HOSTEADA vert_area = 0 hydro_area = 0 skirt_len = 0 for wall in final_walls: vert_area += (wall[1].Length * height) - wall[4] skirt_len += wall[1].Length - wall[5] if wall[2] == True: hydro_area += (wall[1].Length * height) - wall[6] return room, SqFeetToSqMeters(vert_area), SqFeetToSqMeters(hydro_area) if room.GetParameters("CUARTO HUMEDO")[0].AsInteger() == 1 else 0, FeetToMeters(skirt_len) data = list() for room in FilteredElementCollector(doc).OfCategory(Autodesk.Revit.DB.BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements(): if room.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble() != 0.0 and room.GetParameters("Phase")[0].AsElementId() == phase.Id: data.append(RoomCalc(room,excluded,hydro)) t = Transaction(doc,"Cálculo Áreas Habitaciones") t.Start() for line in data: print("Habitación" + line[0].LookupParameter("Number").AsString() + " - " + line[0].LookupParameter("Name").AsString() + ": PARED " + str(line[1]) + " m2, PARED CARTON YESO " + str(line[2]) + " m2, RODAPIE " + str(line[3]) + " m." ) line[0].LookupParameter("PARED NETA").SetValueString(str(line[1])+" m²") line[0].LookupParameter("PARED NETA CARTON YESO").SetValueString(str(line[2])+" m²") line[0].LookupParameter("RODAPIE").SetValueString(str(line[3])+" m") t.Commit() # COMPROBAR QUE EL PARÁMETRO EXISTE, ETC # AÑADIR LA MEDICIÓN DE HYDRO POR TIPO DE MURO #REPORT TIME endtime ="\nHe tardado " + str(timer.get_time())[:3] + " segundos en llevar a cabo esta tarea." print(endtime)
__author__ = 'Carlos Romero' #for timing from pyrevit.coreutils import Timer timer = Timer() from Autodesk.Revit.DB import Transaction, FilteredElementCollector, BuiltInCategory import Autodesk.Revit.DB as DB import clr doc = __revit__.ActiveUIDocument.Document uidoc = __revit__.ActiveUIDocument rooms = DB.FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms) flag = False for e in rooms: try: a = e.Geometry except: print("No geometry in room number " + str(e.Number)) flag = True if not flag: print("All model rooms have geometry.") #for timing endtime = "It took me " + str(timer.get_time()) + " seconds to calculate this." print(endtime)
print("Number of Southeast Facing Walls: " + str(len(SEWalls))) print("Number of Southwest Facing Walls: " + str(len(SWWalls))) print("Number of Northwest Facing Walls: " + str(len(NWWalls))) print('----------------------------------') print("Total Number of Windows: " + str(len(windows))) output = script.get_output() output.set_width(600) chart = output.make_line_chart() chart.data.labels = ['North', 'East', 'South', 'West'] WallsChart = chart.data.new_dataset('Wall Total') WallsChart.data = [(sum(NWallArea) + sum(NTotal)), (sum(EWallArea) + sum(ETotal)), (sum(SWallArea) + sum(STotal)), (sum(WWallArea) + sum(WTotal))] WallsChart.set_color(233, 30, 99, 0.2) WindowsChart = chart.data.new_dataset('Window Openings') WindowsChart.data = [sum(NTotal), sum(ETotal), sum(STotal), sum(WTotal)] WindowsChart.set_color(3, 169, 244, 0.6) #chart.randomize_colors() chart.draw() #print("Total Number of Doors: " + str(len(doors))) endtime = "It took me: " + str( timer.get_time()) + " seconds to perform this task." print(endtime)
runtime = engine.Runtime return engine, runtime def shutdown(runtime): runtime.Shutdown() engine_times = [] output_times = [] for idx in range(1, MAX_TESTS): engine, runtime = make_engine() engine_timer = Timer() run(engine, runtime) eng_time = engine_timer.get_time() shutdown(runtime) engine_times.append(eng_time) output_timer = Timer() print('Engine {}: {}'.format(idx, eng_time)) output_times.append(output_timer.get_time()) chart = this_script.output.make_line_chart() # chart.options.scales = {'xAxes': [{'ticks': {'fixedStepSize': 5}, 'type': 'category', 'position': 'bottom'}], # 'yAxes': [{'ticks': {'fixedStepSize': 10}}]} chart.data.labels = [x for x in range(0, MAX_TESTS + 1)] engine_dataset = chart.data.new_dataset('engine_timer') engine_dataset.set_color(0xc3, 0x10, 0x10, 0.4)
plantilla_colores = {} for key in plantilla_capas.keys(): code = plantilla_dwg[plantilla_capas[key]] plantilla_colores[key] = Color(int(code[0]), int(code[1]), int(code[2])) t = Transaction(doc, "Cambio Colores DWG") t.Start() for capa in capas_dwg: if capa.Name in plantilla_colores.keys(): capa.LineColor = plantilla_colores[capa.Name] print("Color de Capa '{}' cambiado en '{}'.".format( capa.Name, capa.Parent.Name)) #Movemos los cad para que se recarguen, mostrando los cambios en color. for cad in [item for sublist in [FilteredElementCollector(doc).OfCategoryId(cat.Id).WhereElementIsNotElementType().ToElements()\ for cat in doc.Settings.Categories if cat.Name.ToString()[-4:] == ".dwg"] for item in sublist]: if cad.Pinned == False: ElementTransformUtils.MoveElement(doc, cad.Id, XYZ.BasisX) ElementTransformUtils.MoveElement(doc, cad.Id, XYZ.BasisX.Negate()) else: cad.Pinned = False ElementTransformUtils.MoveElement(doc, cad.Id, XYZ.BasisX) ElementTransformUtils.MoveElement(doc, cad.Id, XYZ.BasisX.Negate()) cad.Pinned = True t.Commit() endtime = "\nHe tardado " + str(round( timer.get_time(), 2)) + " segundos en llevar a cabo esta tarea." print(endtime)
return "South" elif x < -0.3090 and x > -0.9335 and y < -0.3583 and y > -0.9510: return "Southwest" elif x <= -0.8660 and x >= -1 and y <= 0.5000 and y >= -0.3583: return "West" elif x < -0.3826 and x > -0.8660 and y < 0.9238 and y > 0.5000: return "Northwest" else: return "Sin orientacion" res = [] for x, y in zip(ori_x, ori_y): res.append(ori(x, y)) t = Transaction(doc, "Orientacion Muros") t.Start() for wall, dir in zip(new_walls, res): if wall.LookupParameter("Orientacion"): try: wall.LookupParameter("Orientacion").Set(dir) except: print("No se puede escribir en el parametro de uno de los muros.") t.Commit() #for timing endtime = "He tardado: " + str(timer.get_time()) + " segundos." print(endtime)
# output = script.get_output() # output.set_width(600) # chart = output.make_bar_chart() # chart.data.labels = ['North', 'Northeast', 'East', 'Southeast', 'South', 'Southwest', 'West', 'Northwest'] # WallsChart = chart.data.new_dataset('Wall Total') # WallsChart.data = [100, 100, 100, 100, 100, 100, 100, 100] # WallsChart.set_color(233, 30, 99, 0.3) # WindowsChart = chart.data.new_dataset('Window Openings') # WindowsChart.data = [round((sum(NTotal) / (sum(NWallArea) + sum(NTotal)) * 100), 1), round((sum(STotal) / (sum(SWallArea) + sum(STotal)) * 100), 1), round((sum(ETotal) / (sum(EWallArea) + sum(ETotal)) * 100), 1), round((sum(WTotal) / (sum(WWallArea) + sum(WTotal)) * 100), 1)] # WindowsChart.set_color(3, 169, 244, 0.6) #FortyMark = chart.data.new_dataset('40% Mark') #FortyMark.data = [(((sum(NWallArea)) + (sum(NTotal))) * .4), (((sum(NEWallArea)) + (sum(NETotal))) * .4)] #FortyMark.set_color(51, 255, 54, 0.7) #chart.randomize_colors() #chart.draw() #print("Total Number of Doors: " + str(len(doors))) endtime ="It took me: " + str(timer.get_time()) + " seconds to perform this task." print(endtime)