Example #1
0
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)
Example #2
0
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()
Example #3
0
application = uiapp.Application

# Pick an action
process = ["HVAC Models", "Other Models"]
pickedProcess = forms.SelectFromList.show(process,
                                          button_name='Select Item',
                                          multiselect=False)

if len(collectorFiles) > 0:
    for aDoc in collectorFiles:

        openedDoc = OpenFiles(aDoc, application, audit=False)
        t = Transaction(openedDoc, 'Check QAQC Elements')
        t.Start()
        print(str(openedDoc.Title) + ' Opened')
        workshareOp = WorksharingSaveAsOptions()
        # Define the name and location of excel file
        rawTitle = re.split('detached', openedDoc.Title)[0]
        title = rawTitle[0:len(rawTitle) - 1]
        fileName = destinationFolder + '\\' + title + '.xlsx'
        # Define and Open Excel File
        excelFile = EAMQcUtils.ExcelOpener(fileName)
        # Create a blank intro Sheet
        blank = []
        # EAMQcUtils.ExcelWriter(excelFile, 'INTRO', 1, 0, blank)
        # Create View

        threeDViews = []

        viewFamilyTypes = FilteredElementCollector(openedDoc).OfClass(
            ViewFamilyType).ToElements()
Example #4
0
__doc__ = 'Extract information from csv file and batch apply parameter value changes.'\
          'Format of csv: "model name, element Id, parameter name, new parameter value".'\
            'Step 1: Select the csv File'\
            'Step 2: Select the Revit Files'\
            'Step 3: Select the directory new models to be placed.'
uiapp = UIApplication(doc.Application)
application = uiapp.Application

if len(collectorFiles) > 0:
    for aDoc in collectorFiles:
        openedDoc = OpenFiles(aDoc, application, audit=False)
        t = Transaction(openedDoc, "Apply Parameters")
        t.Start()
        print(str(openedDoc.Title) + ' Opened')
        workshareOp = WorksharingSaveAsOptions()
        # Define the name and location of excel file
        rawTitle = re.split('detached', openedDoc.Title)[0]
        title = rawTitle[0:len(rawTitle) -1]
        print(str(title) + ' is being modified:')
        for line in Importcsv(collectorCSVFile):
            modelName = line[0]
            id = line[1]
            parameterName = line[2]
            parameterValue = line[3]
            v1 = ()
            if modelName == title:
                element = ()
                try:
                    element = openedDoc.GetElement(ElementId(int(id)))
                except:
        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()