Beispiel #1
0
def get_datafile(reverse):
    global append_mode
    datafile = script.get_document_data_file("pyApex_Constraints", "pym")
    saved_list = []

    if os.path.exists(datafile):
        if reverse == False:
            td = TaskDialog("Constraints")
            td.MainInstruction = "File with elements saved after previous run found.\nHow to deal with it?"
            td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
                              "Remove it and replace")
            td.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
                              "Append new data")
            td.AllowCancellation = True
            taskDialogResult = td.Show()
            if taskDialogResult == TaskDialogResult.Cancel:
                return None, None
            elif taskDialogResult == TaskDialogResult.CommandLink1:
                append_mode = False
            else:
                append_mode = True

        if append_mode:
            f = open(datafile, 'r')
            saved_list = pickle.load(f)
            f.close()

    # remove duplicates
    ids = list(set(saved_list))
    return datafile, ids
Beispiel #2
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))
Beispiel #3
0
from Autodesk.Revit.UI import (TaskDialog, TaskDialogCommonButtons,
                               TaskDialogCommandLinkId, TaskDialogResult)

title = 'Task Dialog Title'
dialog = TaskDialog(title)

# Properties
dialog.MainInstruction = 'Text Header'
dialog.MainContent = 'Text Content'
dialog.FooterText = 'Footer Text'
dialog.VerificationText = 'Verification Text'
# dialog.ExpandedContent = expanded_content

# Settings
dialog.TitleAutoPrefix = False
dialog.AllowCancellation = True

# Add Button
dialog.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Yes

# Set Default Button
dialog.DefaultButton = TaskDialogResult.None

# Add Command Link
dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
                      'Command Button Text', 'Command Button Sub Text')
dialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
                      'Command Button Text 2', 'Command Button Sub Text 2')

result = dialog.Show()