Example #1
0
def event_handler_function(sender, args):
    print(15*"-" + "event_handler file opened" + 15*"-")
    doc = __revit__.ActiveUIDocument.Document
    now_utc = str(datetime.datetime.utcnow())
    log_path = "d:/delme/model_open_log.txt"

    if doc.IsWorkshared:
        doc_central_path = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath())
        doc_local_path = doc.PathName
        doc_path = doc_central_path
        in_central = doc_central_path == doc_local_path
        if in_central:
            task_dialog = TaskDialog("rvt_fixme_central_model_warning")
            task_dialog.Id = "rvt_fixme_central_model_warning"
            task_dialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning
            task_dialog.Title = "Attention - you are in central model!!!"
            task_dialog.MainContent = task_dialog.Title
            task_dialog.TitleAutoPrefix = True
            task_dialog.AllowCancellation = True
            task_dialog.Show()
        model_name = op.basename(doc_path)
        model_path = op.dirname(doc_path)
        # model_central_name = model_name.split("_" + rvt_user)[0]
        model_central_name = model_name.split(".rvt")[0]
        assume_fix_tasks_dir = op.join(model_path, "RVT_fixme")
        ini = op.join(assume_fix_tasks_dir, "fixme_{}.ini".format(model_central_name))
        jsn = op.join(assume_fix_tasks_dir, "fixme_{}_ids.json".format(model_central_name))

        # print("searching for fixme: {}".format(ini))
        if op.exists(ini):
            print("- found corresponding RVT_fixme ini to this model.")
            # print(doc_path)
            # print("file was opened at {0}".format(now_utc))
            # print("ini found at: {0}".format(ini))
            if doc.IsWorkshared:
                import on_ws_model_opened
                print("- workshared model found at:\n- {0}".format(doc_path))
                # print("attempt reload")
                # reload(on_ws_model_opened)
                # print("after_reload")
                on_ws_model_opened.connect_to_rvt(ini)

        # print("searching for fixme: {}".format(jsn))
        if op.exists(jsn):
            print("- found corresponding RVT_fixme json to this model.")
            if doc.IsWorkshared:
                import on_ws_model_opened
                print("- workshared model found at:\n- {0}".format(doc_path))
                on_ws_model_opened.connect_to_rvt(jsn)

        with open(log_path, "a") as model_log:
            model_log.write("ws file was opened at \n- {0}\n-".format(now_utc))
Example #2
0
        fRule = FilterStringRule(pvp, fnrv, values[count], True)
    elif 'Interger' in str(i.StorageType):
        fnrv = FilterNumericEquals()
        fRule = FilterIntegerRule(pvp, fnrv, int(values[count]))
    elif 'Double' in str(i.StorageType):
        fnrv = FilterNumericEquals()
        fRule = FilterDoubleRule(pvp, fnrv, float(values[count]), 0.001)
    elif 'ElementId' in str(i.StorageType):
        fnrv = FilterNumericEquals()
        fRule = FilterElementIdRule(pvp, fnrv, ElementId(int(values[count])))
    fRules.append(fRule)
    count += 1
# Filter all elements based on parameter values selected
paramFilters = ElementParameterFilter(fRules)
ele = filter.WherePasses(paramFilters).ToElements()
elements = []
for i in ele:
    elements.append(i)

# Task Dialogue Creation
dialog = TaskDialog('Warning')
dialog.CommonButtons = TaskDialogCommonButtons.Ok
dialog.DefaultButton = TaskDialogResult.Ok
dialog.Title = 'Warning'
dialog.MainInstruction = 'You are about to select ' + str(
    len(elements)) + ' elements'
bool = dialog.Show()
if str(bool) == 'Ok':
    revit.get_selection().set_to(elements)
else:
    pass