-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release/46beta
- Loading branch information
Showing
15 changed files
with
448 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...yRevit.tab/Drawing Set.panel/Sheets.pulldown/ReOrder Sheets.pushbutton/ReOrderWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
Title="Re-Order Sheets" Height="700" Width="600" ShowInTaskbar="False" ResizeMode="CanResizeWithGrip" | ||
WindowStartupLocation="CenterScreen" HorizontalContentAlignment="Center"> | ||
<Window.Resources> | ||
<Style x:Key="IndexColumnStyle" TargetType="{x:Type DataGridCell}"> | ||
<Setter Property="Foreground" Value="Orange"/> | ||
</Style> | ||
|
||
<Style x:Key="DefaultColumnStyle" TargetType="{x:Type DataGridCell}"> | ||
<Setter Property="ToolTip" Value="{Binding tooltip}"/> | ||
<Style.Triggers> | ||
<DataTrigger Binding="{Binding printable}" Value="False"> | ||
<Setter Property="Foreground" Value="#bdbdbd" /> | ||
</DataTrigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
<ControlTemplate x:Key="Default" TargetType="{x:Type DataGridCell}"> | ||
<StackPanel Background="White"> | ||
<GridViewRowPresenter Content="{TemplateBinding Content}" | ||
Columns="{TemplateBinding GridView.ColumnCollection}"/> | ||
</StackPanel> | ||
</ControlTemplate> | ||
|
||
<ControlTemplate x:Key="NonPrintableSheet" TargetType='{x:Type DataGridCell}'> | ||
<StackPanel Background="#f6f6f6"> | ||
<GridViewRowPresenter Content="{TemplateBinding Content}" | ||
Columns="{TemplateBinding GridView.ColumnCollection}"/> | ||
</StackPanel> | ||
</ControlTemplate> | ||
|
||
</Window.Resources> | ||
<DockPanel Margin="10"> | ||
<StackPanel DockPanel.Dock="Top"> | ||
<TextBlock Text="Select Order Parameter:" /> | ||
<ComboBox x:Name="orderparams_cb" Height="22" Margin="0,5,0,0" SelectionChanged="selection_changed"/> | ||
<TextBlock TextWrapping="WrapWithOverflow" Margin="0,5,0,10"> | ||
List of the sheets (Drag to manually reorder): | ||
</TextBlock> | ||
</StackPanel> | ||
<Grid DockPanel.Dock="Bottom" Margin="0,10,0,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Button x:Name="reorder_b" | ||
Margin="5,0,0,0" | ||
Grid.Column="2" Grid.Row="0" | ||
Height="25" | ||
Content="Re-Order" | ||
Click="reorder_items"/> | ||
</Grid> | ||
<Grid DockPanel.Dock="Left" Width="30" Margin="0,0,10,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
<Button Grid.Row="0" Margin="0,0,0,5" Content=">>> Top" Click="move_to_top"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
<Button Grid.Row="1" Margin="0,0,0,5" Content="10 >>" Click="move_10_to_top"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
<Button Grid.Row="2" Margin="0,0,0,5" Content=">" Click="move_1_to_top"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
<Button Grid.Row="3" Margin="0,0,0,5" Content="<" Click="move_1_to_bottom"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
<Button Grid.Row="4" Margin="0,0,0,5" Content="10 <<" Click="move_10_to_bottom"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
<Button Grid.Row="5" Margin="0,0,0,0" Content="Bottom <<<" Click="move_to_bottom"> | ||
<Button.LayoutTransform> | ||
<RotateTransform Angle="-90" /> | ||
</Button.LayoutTransform> | ||
</Button> | ||
</Grid> | ||
<DataGrid x:Name="items_dg" | ||
AutoGenerateColumns="False" | ||
BorderThickness="1" | ||
RowHeaderWidth="0" | ||
CanUserSortColumns="True" | ||
HorizontalGridLinesBrush="#dedede" | ||
VerticalGridLinesBrush="#dedede" | ||
Sorting="sorting_changed"> | ||
<DataGrid.CellStyle> | ||
<Style TargetType="DataGridCell" > | ||
<Setter Property="BorderThickness" Value="0"/> | ||
</Style> | ||
</DataGrid.CellStyle> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="Index" Binding="{Binding order_index}" MinWidth="40" Width="40" IsReadOnly="True" CellStyle="{StaticResource IndexColumnStyle}"/> | ||
<DataGridTextColumn Header="Sheet Number" Binding="{Binding number}" MinWidth="100" Width="100" IsReadOnly="True" CellStyle="{StaticResource DefaultColumnStyle}"/> | ||
<DataGridTextColumn Header="Sheet Name" Binding="{Binding name}" MinWidth="50" Width="*" IsReadOnly="True" CellStyle="{StaticResource DefaultColumnStyle}"/> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
</DockPanel> | ||
</Window> |
Binary file added
BIN
+1.61 KB
...yRevit.tab/Drawing Set.panel/Sheets.pulldown/ReOrder Sheets.pushbutton/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions
148
...tension/pyRevit.tab/Drawing Set.panel/Sheets.pulldown/ReOrder Sheets.pushbutton/script.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
"""Print items in order from a sheet index.""" | ||
#pylint: disable=W0613,E0401,C0103 | ||
from pyrevit import forms | ||
from pyrevit import revit, DB | ||
from pyrevit import script | ||
|
||
|
||
logger = script.get_logger() | ||
|
||
|
||
class ListItem(object): | ||
def __init__(self, view_sheet): | ||
self._item = view_sheet | ||
self.name = self._item.Name | ||
self.number = self._item.SheetNumber | ||
self.printable = self._item.CanBePrinted | ||
self.order_index = 0 | ||
|
||
@property | ||
def revit_item(self): | ||
return self._item | ||
|
||
|
||
class ReOrderWindow(forms.WPFWindow): | ||
def __init__(self, xaml_file_name): | ||
forms.WPFWindow.__init__(self, xaml_file_name) | ||
|
||
self._setup_item_params_combobox() | ||
|
||
@property | ||
def items_list(self): | ||
return self.items_dg.ItemsSource | ||
|
||
@items_list.setter | ||
def items_list(self, value): | ||
self.items_dg.ItemsSource = value | ||
# update oder indices | ||
self._update_order_indices() | ||
|
||
@property | ||
def selected_item_param(self): | ||
return self.orderparams_cb.SelectedItem | ||
|
||
def _update_order_indices(self): | ||
for idx, item in enumerate(self.items_list): | ||
item.order_index = idx | ||
|
||
def _setup_item_params_combobox(self): | ||
items = revit.query.get_sheets() | ||
if items: | ||
item_sample = items[0] | ||
item_params = [x.Definition.Name for x in item_sample.Parameters | ||
if x.StorageType == DB.StorageType.Integer] | ||
order_params = [x for x in item_params if 'order' in x.lower()] | ||
self.orderparams_cb.ItemsSource = sorted(order_params) | ||
self.orderparams_cb.SelectedIndex = 0 | ||
|
||
def _get_ordered_items(self): | ||
items = revit.query.get_sheets(include_noappear=False) | ||
if self.selected_item_param: | ||
items = sorted( | ||
items, | ||
key=lambda x: x.LookupParameter(self.selected_item_param) | ||
.AsInteger() | ||
) | ||
return items | ||
|
||
def _get_selected_nonselected(self): | ||
selected = list(self.items_dg.SelectedItems) | ||
nonselected = [] | ||
for item in self.items_list: | ||
if item not in selected: | ||
nonselected.append(item) | ||
return selected, nonselected | ||
|
||
def _insert_list_in_list(self, src_list, dest_list, index): | ||
max_index = len(dest_list) | ||
if index < 0: | ||
index = 0 | ||
|
||
if index > max_index: | ||
index = max_index | ||
|
||
for item in reversed(src_list): | ||
dest_list.insert(index, item) | ||
|
||
return dest_list | ||
|
||
def selection_changed(self, sender, args): | ||
if self.selected_item_param: | ||
items_list = [ListItem(x) for x in self._get_ordered_items()] | ||
# Show all items | ||
self.items_list = items_list | ||
|
||
def sorting_changed(self, sender, args): | ||
order_param = args.Column.SortMemberPath | ||
if order_param == 'number': | ||
self.items_list = sorted(self.items_list, key=lambda x: x.number) | ||
elif order_param == 'name': | ||
self.items_list = sorted(self.items_list, key=lambda x: x.name) | ||
|
||
def move_to_top(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
new_list = self._insert_list_in_list(selected, non_selected, 0) | ||
self.items_list = new_list | ||
|
||
def move_10_to_top(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
index = self.items_dg.ItemsSource.index(selected[0]) | ||
new_list = self._insert_list_in_list(selected, non_selected, index - 10) | ||
self.items_list = new_list | ||
|
||
def move_1_to_top(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
index = self.items_dg.ItemsSource.index(selected[0]) | ||
new_list = self._insert_list_in_list(selected, non_selected, index - 1) | ||
self.items_list = new_list | ||
|
||
def move_1_to_bottom(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
index = self.items_dg.ItemsSource.index(selected[0]) | ||
new_list = self._insert_list_in_list(selected, non_selected, index + 1) | ||
self.items_list = new_list | ||
|
||
def move_10_to_bottom(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
index = self.items_dg.ItemsSource.index(selected[0]) | ||
new_list = self._insert_list_in_list(selected, non_selected, index + 10) | ||
self.items_list = new_list | ||
|
||
def move_to_bottom(self, sender, args): | ||
selected, non_selected = self._get_selected_nonselected() | ||
new_list = self._insert_list_in_list(selected, | ||
non_selected, | ||
len(non_selected)) | ||
self.items_list = new_list | ||
|
||
def reorder_items(self, sender, args): | ||
self.Close() | ||
with revit.Transaction('Reorder Sheets'): | ||
for item in self.items_list: | ||
idx_param = \ | ||
item.revit_item.LookupParameter(self.selected_item_param) | ||
if idx_param: | ||
idx_param.Set(item.order_index) | ||
|
||
|
||
ReOrderWindow('ReOrderWindow.xaml').ShowDialog() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.