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 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