def OpenFilesandUnload(oFile, app, audit): openOpt = OpenOptions() if audit == True: openOpt.Audit = True else: openOpt.Audit = False openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets wsopt = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) # wsopt.Open(worksetList) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(oFile) currentdoc = app.OpenDocumentFile(modelPath, openOpt) try: DialogBoxShowingEventArgs.OverrideResult(1) except: pass revitLinkType = FilteredElementCollector(doc).OfClass( RevitLinkType).ToElements() for r in revitLinkType: try: r.Unload(None) except: pass saveOp = SaveAsOptions() workOp = WorksharingSaveAsOptions() workOp.SaveAsCentral = True saveOp.SetWorksharingOptions(workOp) title = currentdoc.Title currentdoc.SaveAs(destinationFolder + '\\' + title, saveOp) currentdoc.Close(False)
def OpenFiles(files, app, audit): counter = 0 for oFile in files: openOpt = OpenOptions() if audit == True: openOpt.Audit = True else: openOpt.Audit = False openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets wsopt = WorksetConfiguration( WorksetConfigurationOption.CloseAllWorksets) # wsopt.Open(worksetList) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(oFile) # doc = Application.OpenDocumentFile(modelPath, openOpt) docs = [] currentdoc = app.OpenDocumentFile(modelPath, openOpt) try: DialogBoxShowingEventArgs.OverrideResult(1) except: pass print(str(doc) + ' Opened') counter += 1 docs.append(currentdoc) return docs
def set_coloristic_tag(self, obj): """ Устанавливает коллористические марки. Открывает файл с закрытыми рабочими наборами. Для этого создается конфиг open_opt Проходим по всем документам и панелям, которые переданы в obj Выгружаем связь. Открываем документ. Проверяем можно ли вносить изменения в документ. Пробуем внести изменения. Проходим по всем панелям и уровням. Получаем в документе связи панель по ID. Проходим по всем уровням. Для каждой колористик Tag устанавливаем марку по уровню. Если файл общий. Синхронизироваться. Если файл не общий - просто сохранить. В противном случае закрыть документ """ workset_config_option = WorksetConfigurationOption.CloseAllWorksets workset_config = WorksetConfiguration(workset_config_option) open_opt = OpenOptions() open_opt.SetOpenWorksetsConfiguration(workset_config) app = self.doc.Application for doc, panels in obj.items(): title = doc.Title m_p = ModelPathUtils.ConvertUserVisiblePathToModelPath( doc.PathName) rvt_type = self.rvt_docs[doc] rvt_type.Unload(None) cur_doc = app.OpenDocumentFile(m_p, open_opt) if not cur_doc.IsReadOnly: try: with Transaction(cur_doc, "Вносим изменения") as t: t.Start() for panel, levels in panels.items(): panel = cur_doc.GetElement(ElementId(panel.Id)) for level, mark in levels.items(): level = level if len( level) > 1 else "0" + level panel.LookupParameter( "BDS_ColoristicsTag_Floor" + level).Set(mark) t.Commit() if cur_doc.IsWorkshared: twc_opts = TransactWithCentralOptions() swc_opts = SynchronizeWithCentralOptions() swc_opts.SetRelinquishOptions(RelinquishOptions(True)) swc_opts.Comment = "Атоматическая синхронизация КЖС" cur_doc.SynchronizeWithCentral(twc_opts, swc_opts) cur_doc.Close(True) except: echo(sys.exc_info()[1]) cur_doc.Close(False) else: echo("Файл {} доступен только для чтения".format(title)) cur_doc.Close(False) rvt_type.Load() echo("Обработали связь {}".format(title))
def CreateWorksetConfiguration(batchRvtWorksetConfigurationOption): worksetConfigurationOption = ( WorksetConfigurationOption.CloseAllWorksets if batchRvtWorksetConfigurationOption == BatchRvt.WorksetConfigurationOption.CloseAllWorksets else WorksetConfigurationOption.OpenAllWorksets if batchRvtWorksetConfigurationOption == BatchRvt.WorksetConfigurationOption.OpenAllWorksets else WorksetConfigurationOption.OpenLastViewed) return WorksetConfiguration(worksetConfigurationOption)
def OpenFileCloseWorksets(oFile, app, audit): openOpt = OpenOptions() if audit == True: openOpt.Audit = True else: openOpt.Audit = False openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets wsopt = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(oFile) currentdoc = app.OpenDocumentFile(modelPath, openOpt) try: DialogBoxShowingEventArgs.OverrideResult(1) except: pass return currentdoc
def OpenCloudFiles(modelGUID, projectGUID, app, audit): openOpt = OpenOptions() if audit == True: openOpt.Audit = True else: openOpt.Audit = False # openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets wsopt = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) # wsopt.Open(worksetList) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath( projectGUID, modelGUID) currentdoc = app.OpenDocumentFile(modelPath, openOpt) try: DialogBoxShowingEventArgs.OverrideResult(1) except: pass return currentdoc
def OpenFiles(oFile, app, audit): openOpt = OpenOptions() if audit == True: openOpt.Audit = True else: openOpt.Audit = False openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets # Needed for specific view to work: # wsopt = WorksetConfiguration(WorksetConfigurationOption.OpenAllWorksets) # Better for all elements as faster and unload all links cause worksets closed: wsopt = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) # wsopt.Open(worksetList) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(oFile) currentdoc = app.OpenDocumentFile(modelPath, openOpt) try: DialogBoxShowingEventArgs.OverrideResult(1) except: pass return currentdoc
test_ip = "9.9.9.9" udp_conn = System.Net.Sockets.UdpClient(test_ip, 1) local_addr = udp_conn.Client.LocalEndPoint.Address for nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces( ): ip_props = nic.GetIPProperties() for addr_info in ip_props.UnicastAddresses: if local_addr.ToString() == addr_info.Address.ToString(): active_nic = nic.Description project = os.environ["RVT_QC_PRJ"] model_path = os.environ["RVT_QC_PATH"] pc_stats = os.environ["pc_stats"] rvt_path = FilePath(model_path) ws_conf = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) open_opt = OpenOptions() open_opt.SetOpenWorksetsConfiguration(ws_conf) sync_opt = SynchronizeWithCentralOptions() relinquish_opt = RelinquishOptions(True) sync_opt.SetRelinquishOptions(relinquish_opt) sync_opt.SaveLocalAfter = True # sync_opt.Compact = True sync_opt.Comment = "syncing" trans_opt = TransactWithCentralOptions() print(time_now) print("machine stats:\n{}".format(pc_stats)) print(active_nic) print("timing: {} {} times".format(model_path, iterations))
for file in os.listdir(models): if file.endswith(".rvt"): print(str(file)) files.append(str(file)) counter = 0 worksetList = [] __doc__ = 'Open projects and remove all the links.' \ 'Please do not use lightly' # Open Files for oFile in files: openOpt = OpenOptions() openOpt.Audit = False openOpt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets wsopt = WorksetConfiguration(WorksetConfigurationOption.OpenLastViewed) wsopt.Open(worksetList) openOpt.SetOpenWorksetsConfiguration(wsopt) modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(models + oFile) __revit__.OpenAndActivateDocument(modelPath, openOpt, False) # Define doc uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document placeholderfile = "C:\\Users\\loum\\Desktop\\Empty Project.rvt" selection = [ doc.GetElement(id) for id in __revit__.ActiveUIDocument.Selection.GetElementIds() ]