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 SaveCloudModelandChangeName(document, filePath, Name): worksharingOptions = WorksharingSaveAsOptions() worksharingOptions.SaveAsCentral = True saveOpt = SaveAsOptions() saveOpt.SetWorksharingOptions(worksharingOptions) saveOpt.OverwriteExistingFile = True saveOpt.Compact = True document.SaveAs(filePath + Name + ".rvt", saveOpt) document.Close()
if v1.StorageType == StorageType.Integer: try: element.LookupParameter(parameterName).Set(int(parameterValue)) print("Applied change {0} as {1}".format(id, parameterValue)) except: print("Error Applying the value to {0} ".format(str(id)) + parameterName + " as integer") elif v1.StorageType == StorageType.String: try: element.LookupParameter(parameterName).Set(str(parameterValue)) print("Applied change {0} as {1}".format(id, parameterValue)) except: print("Error Applying the value to {0} ".format(str(id)) + parameterName + " as string") elif v1.StorageType == StorageType.Double: try: element.LookupParameter(parameterName).Set(float(parameterValue)) print("Applied change {0} as {1}".format(id, parameterValue)) except: print("Error Applying the value to {0} ".format(str(id)) + parameterName + " as double") else: print("Error Applying the value to {0} ".format(str(id)) + parameterName + " format error") t.Commit() saveOp = SaveAsOptions() workOp = WorksharingSaveAsOptions() workOp.SaveAsCentral = True saveOp.SetWorksharingOptions(workOp) saveAsTitle = openedDoc.Title openedDoc.SaveAs(destinationFolder + '\\' + saveAsTitle, saveOp) openedDoc.Close(False) print("--------------------------")
model_path) print("currently processing: {}".format(model_path)) ws_conf = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets) open_opt = OpenOptions() open_opt.Audit = True open_opt.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets open_opt.SetOpenWorksetsConfiguration(ws_conf) save_opt = SaveAsOptions() if os.path.exists(new_target_path): print("warning! overwriting: {}".format(new_target_path)) save_opt.OverwriteExistingFile = True model_doc = app.OpenDocumentFile(rvt_path, open_opt) if model_doc.IsWorkshared: ws_opt = WorksharingSaveAsOptions() ws_opt.SaveAsCentral = True if TransmissionData.IsDocumentTransmitted(rvt_model_path): print("removing transmit : {}".format(model_path)) ws_opt.ClearTransmitted = True save_opt.SetWorksharingOptions(ws_opt) print("opened : {}".format(model_path)) model_doc.SaveAs(new_target_path, save_opt) print("saved as : {}".format(new_target_path)) model_doc.Close() print("closed") sys.exit()