Beispiel #1
0
    def __init__(self, xaml_file_name):
        forms.WPFWindow.__init__(self, xaml_file_name)

        self.sheet_cat_id = \
            revit.query.get_category(DB.BuiltInCategory.OST_Sheets).Id

        self._setup_printers()
        self._setup_print_settings()
        self.schedules_cb.ItemsSource = self._get_sheet_index_list()
        if not self.schedules_cb.ItemsSource:
            forms.alert("No Sheet Lists (Schedules) found in current project",
                        exitscript=True)
        self.schedules_cb.SelectedIndex = 0

        item_cstyle = self.sheets_lb.ItemContainerStyle

        item_cstyle.Setters.Add(
            Windows.Setter(Windows.Controls.ListViewItem.AllowDropProperty,
                           True))

        item_cstyle.Setters.Add(
            Windows.EventSetter(
                Windows.Controls.ListViewItem.PreviewMouseLeftButtonDownEvent,
                Windows.Input.MouseButtonEventHandler(
                    self.preview_mouse_down)))

        item_cstyle.Setters.Add(
            Windows.EventSetter(Windows.Controls.ListViewItem.DropEvent,
                                Windows.DragEventHandler(self.drop_sheet)))
Beispiel #2
0
    def __init__(self, xaml_file_name):
        forms.WPFWindow.__init__(self, xaml_file_name)

        for cat in revit.doc.Settings.Categories:
            if cat.Name == 'Sheets':
                self.sheet_cat_id = cat.Id

        self._setup_printers()
        self._setup_print_settings()
        self.schedules_cb.ItemsSource = self._get_sheet_index_list()
        self.schedules_cb.SelectedIndex = 0

        item_cstyle = self.sheets_lb.ItemContainerStyle

        item_cstyle.Setters.Add(
            Windows.Setter(Windows.Controls.ListViewItem.AllowDropProperty,
                           True))

        item_cstyle.Setters.Add(
            Windows.EventSetter(
                Windows.Controls.ListViewItem.PreviewMouseLeftButtonDownEvent,
                Windows.Input.MouseButtonEventHandler(
                    self.preview_mouse_down)))

        item_cstyle.Setters.Add(
            Windows.EventSetter(Windows.Controls.ListViewItem.DropEvent,
                                Windows.DragEventHandler(self.drop_sheet)))
Beispiel #3
0
 def start_drag(self, sender, args):
     name_formatter = args.OriginalSource.DataContext
     Windows.DragDrop.DoDragDrop(
         self.formatters_wp,
         Windows.DataObject("name_formatter", name_formatter),
         Windows.DragDropEffects.Copy
         )
Beispiel #4
0
 def preview_drag(self, sender, args):
     mouse_pos = Forms.Cursor.Position
     mouse_po_pt = Windows.Point(mouse_pos.X, mouse_pos.Y)
     self._drop_pos = \
         self.template_tb.GetCharacterIndexFromPoint(
             point=self.template_tb.PointFromScreen(mouse_po_pt),
             snapToText=True
             )
     self.template_tb.SelectionStart = self._drop_pos
     self.template_tb.SelectionLength = 0
     self.template_tb.Focus()
     args.Effects = Windows.DragDropEffects.Copy
     args.Handled = True
Beispiel #5
0
    def _setup_event_telemetry_checkboxes(self):
        supportedEvents = EventUtils.GetSupportedEventTypes()
        for event_type in coreutils.get_enum_values(EventType):
            # verify event type is supported in telemetry system
            # grab the two parts of the event type name
            api_name, api_event = str(event_type).split('_')

            # figure out the namespace
            api_namespace = 'Autodesk.Revit.ApplicationServices.'
            if api_name in ['UIApplication', 'AddInCommandBinding']:
                api_namespace = 'Autodesk.Revit.UI.'

            # figure out the ui title
            api_title = api_event
            api_obj = api_name + '.' + api_event

            cbox = Controls.CheckBox()
            cbox.Margin = Windows.Thickness(0, 10, 0, 0)
            cbox.FontFamily = Windows.Media.FontFamily("Consolas")
            cbox.IsChecked = False
            tblock = Controls.TextBlock()
            tblock.Margin = Windows.Thickness(0, 2, 0, 0)
            # if event does not have interesting telemetry data, hide from user
            if event_type in [
                    EventType.AddInCommandBinding_BeforeExecuted,
                    EventType.AddInCommandBinding_CanExecute,
                    EventType.AddInCommandBinding_Executed,
                    EventType.Application_JournalUpdated
            ]:
                cbox.IsEnabled = False
                cbox.Visibility = Windows.Visibility.Collapsed

            # if the event type is not supported in running revit, inform user
            elif event_type not in supportedEvents:
                cbox.IsEnabled = False
                tblock.Inlines.Add(
                    Documents.Run("{}\n".format(' '.join(
                        coreutils.split_words(str(api_title))))))
                tblock.Inlines.Add(
                    Documents.Run("Not Supported in this Revit Version\n"))

            # if event is JournalCommandExecuted, create better user interface
            elif event_type == EventType.Application_JournalCommandExecuted:
                tblock.Inlines.Add(Documents.Run("Command Executed\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "Event Type:               journal-command-exec\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "Tracks execution of commands from active journal file. Includes:\n"
                    ))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  Builtin Commands (e.g. ID_OBJECTS_WALL)\n"))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  Thirdparty Commands (e.g. CustomCtrl_%CustomCtrl_%Site Designer%Modify%Sidewalk)\n"
                    ))
                tblock.Inlines.Add(
                    Documents.Run(
                        "  pyRevit Commands (e.g. CustomCtrl_%CustomCtrl_%pyRevit%pyRevit%Settings)\n"
                    ))

            # otherwise prepare the option for the event type
            elif event_type in supportedEvents:
                tblock.Inlines.Add(
                    Documents.Run("{}\n".format(' '.join(
                        coreutils.split_words(str(api_title))))))
                tblock.Inlines.Add(Documents.Run("API Event Type:           "))
                hyperlink = Documents.Hyperlink(Documents.Run(api_obj + "\n"))
                hyperlink.NavigateUri = \
                    System.Uri(apidocs.make_event_uri(api_namespace + api_obj))
                hyperlink.Click += self.handle_url_click
                tblock.Inlines.Add(hyperlink)
                tblock.Inlines.Add(
                    Documents.Run("pyRevit Event/Hook Name:  {}".format(
                        EventUtils.GetEventName(event_type))))
            cbox.Content = tblock
            self.event_telemetry_sp.Children.Add(cbox)
Beispiel #6
0
 def _make_column_datatemplate(self, package_param_name):
     dtobj = Windows.DataTemplate()
     template = self.dt_template.format(param=package_param_name)
     return wpf.LoadComponent(dtobj, framework.StringReader(template))