コード例 #1
0
def task_dialog(type_mes, msg, data=None):
    """
    For create task dialog with error and message

    :param type_mes: info or error
    :type type_mes: str
    :param msg: Message for window
    :type msg: str
    :param data: Text for expanded content
    :type data: []
    """

    window = UI.TaskDialog('Export CAD')
    window.TitleAutoPrefix = False

    if type_mes == 'info':
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconInformation
        window.MainInstruction = 'Info'
        window.MainContent = msg
    else:
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconError
        window.MainInstruction = 'Error'
        window.MainContent = msg

    if data:
        window.ExpandedContent = '\n'.join(data)

    window.CommonButtons = UI.TaskDialogCommonButtons.Ok

    window.Show()
コード例 #2
0
def task_dialog(type_mes, msg, data=None):
    """
    For create task dialog with error and message

    :param type_mes: info or error
    :type type_mes: str
    :param msg: Message for window
    :type msg: str
    :param data: Text for expanded content
    :type data: list
    """

    window = UI.TaskDialog('Заполнение MCP параметров')
    window.TitleAutoPrefix = False

    if type_mes == 'info':
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconInformation
        window.MainInstruction = 'Info'
        window.MainContent = msg
    else:
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconWarning
        window.MainInstruction = 'Error'
        window.MainContent = msg
        window.FooterText = ("<a href=\"{}\"> ".format(URL_TO_DOCUMENTATION) +
                             "Нажмите сюда, чтобы открыть документацию</a>")
        logger.error(msg)

    if data:
        window.ExpandedContent = data if isinstance(data, str) else '\n'.join(data)

    window.CommonButtons = UI.TaskDialogCommonButtons.Ok

    window.Show()
コード例 #3
0
    def __init__(self,
                 instruction,
                 commands=None,
                 buttons=None,
                 title='Task Dialog',
                 content='',
                 title_prefix=False,
                 show_close=False,
                 footer='',
                 expanded_content='',
                 verification_text=''):

        super(TaskDialog, self).__init__(UI.TaskDialog(title))
        self.dialog = self._revit_object

        # Settings
        self.dialog.TitleAutoPrefix = title_prefix
        self.dialog.AllowCancellation = show_close

        # Properties
        self.dialog.Title = title
        self.dialog.MainInstruction = instruction
        self.dialog.MainContent = content
        self.dialog.FooterText = footer
        self.dialog.ExpandedContent = expanded_content
        self.dialog.VerificationText = verification_text
        self.verification_checked = None if not verification_text else False

        # Add Buttons
        self.buttons = buttons or []
        common_buttons_names = []
        for button_name in [b.capitalize() for b in self.buttons]:
            if button_name not in self._common_buttons:
                raise RpwValueError('TaskDialogCommonButtons member',
                                    button_name)
            button_full_name = 'UI.TaskDialogCommonButtons.' + button_name
            common_buttons_names.append(button_full_name)

        if common_buttons_names:
            common_buttons = eval('|'.join(common_buttons_names))
            self.dialog.CommonButtons = common_buttons

        # Set Default Button
        self.dialog.DefaultButton = UI.TaskDialogResult.None

        # Validate Commands
        commands = commands or []
        if len(commands) > 4:
            raise RpwValueError('4 or less command links', len(commands))

        # Process Commands
        self.commands = {}
        for link_index, command_link in enumerate(commands, 1):
            command_id = 'CommandLink{}'.format(link_index)
            command_link._id = getattr(UI.TaskDialogCommandLinkId, command_id)
            self.commands[command_id] = command_link
            self.dialog.AddCommandLink(command_link._id, command_link.text,
                                       command_link.subtext)
コード例 #4
0
    def __init__(self, content, title='Alert', header='', exit=False):
        dialog = UI.TaskDialog(title)
        dialog.TitleAutoPrefix = False
        dialog.MainInstruction = header
        dialog.MainContent = content
        self.result = dialog.Show()

        if exit:
            sys.exit(1)
コード例 #5
0
def get_path(prefix):
    window = UI.FileSaveDialog("Файлы AutoCAD 2013 DWG (*.dwg)|*.dwg")
    window.InitialFileName = prefix
    window.Title = 'Choose folder and inter your prefix or ~ for ignore'
    window.Show()

    path = window.GetSelectedModelPath()

    if path:
        string_path = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(path)

        logger.debug('Get path from user: <{}>'.format(string_path))
        return string_path

    raise ElemNotFound('Cant get path from user')
コード例 #6
0
    def __init__(self, message, title='Alert', heading=''):
        """
        Creates Standard Revit Alert.

        Args:
            message (str): TaskDialog Message
            title (str, optional): TaskDialog Title
            heading (str, optional): TaskDialog Message Heading

        Usage:
            >>> Alert('Your Message', title="Title", heading="Some Heading")
        """
        # todo: add button settings and return values
        dialog = UI.TaskDialog(title)
        dialog.MainInstruction = heading
        dialog.MainContent = message
        self.result = dialog.Show()
コード例 #7
0
def task_dialog(msg):
    """
    For create task dialog with error and message

    :param msg: Message for window
    :type msg: str
    """

    window = UI.TaskDialog('Edit crop')
    window.TitleAutoPrefix = False

    window.MainIcon = UI.TaskDialogIcon.TaskDialogIconError
    window.MainInstruction = 'Error'
    window.MainContent = msg

    window.CommonButtons = UI.TaskDialogCommonButtons.Ok
    window.Show()
コード例 #8
0
    def __init__(self, message, title='Alert', heading='', exit=False):
        """
        Args:
            message (str): TaskDialog Message
            title (str, optional): TaskDialog Title
            heading (str, optional): TaskDialog Message Heading
            exit (bool, optional): Exit Script after Dialog. Useful for displayin Errors. Default is False

        Usage:
            >>> Alert('Your Message', title="Title", heading="Some Heading")
            >>> Alert('You need to select Something', exit=True)
        """
        dialog = UI.TaskDialog(title)
        dialog.MainInstruction = heading
        dialog.MainContent = message
        self.result = dialog.Show()

        if exit:
            sys.exit(1)
コード例 #9
0
def task_dialog(type_mes, msg, data=None):
    window = UI.TaskDialog('Result sheet number')
    window.TitleAutoPrefix = False

    if type_mes == 'info':
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconInformation
        window.MainInstruction = 'Info'
        window.MainContent = msg
    else:
        window.MainIcon = UI.TaskDialogIcon.TaskDialogIconError
        window.MainInstruction = 'Error'
        window.MainContent = msg

    if data:
        window.ExpandedContent = '\n'.join(data.values())

    window.CommonButtons = UI.TaskDialogCommonButtons.Ok

    window.Show()
コード例 #10
0
 def sample_callback():
     print('Calling B')
     d = UI.TaskDialog("Revit Build Information")
     d.MainInstruction = "Button 1"
     d.Show()
コード例 #11
0
 def wrapped(*args, **kwargs):
     dpId = UI.DockablePanes.BuiltInDockablePanes.ProjectBrowser
     pB = UI.DockablePane(dpId)
     r = func(*args, **kwargs)
     pB.Show()
     return r