Skip to content

Commit

Permalink
Merge branch 'develop' into release/46beta
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Oct 28, 2018
2 parents b1db3a8 + 997c4f1 commit 58cc1ad
Show file tree
Hide file tree
Showing 15 changed files with 448 additions and 68 deletions.
7 changes: 6 additions & 1 deletion dev/WPFEdit/WPFEdit/WPFEdit.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -106,6 +106,11 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\..\..\extensions\pyRevitTools.extension\pyRevit.tab\Drawing Set.panel\Sheets.pulldown\ReOrder Sheets.pushbutton\ReOrderWindow.xaml">
<Link>Tools\ReOrderWindow.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\..\..\extensions\pyRevitTools.extension\pyRevit.tab\Modify.panel\edit1.stack3\ReValue.pushbutton\ReValueWindow.xaml">
<Link>Tools\ReValueWindow.xaml</Link>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'Selected Line Coordinates',
'Model / Detail / Sketch Lines',
'Project Parameters',
'Unused Shared Parameters',
'Data Schemas',
'Data Schema Entities',
'Sketch Planes',
Expand Down Expand Up @@ -103,27 +104,41 @@
c.Category.Name))

elif selected_switch == 'Project Parameters':
pm = revit.doc.ParameterBindings
it = pm.ForwardIterator()
it.Reset()
while it.MoveNext():
p = it.Key
b = pm[p]
if isinstance(b, DB.InstanceBinding):
bind = 'Instance'
elif isinstance(b, DB.TypeBinding):
bind = 'Type'
else:
bind = 'Uknown'

print('PARAM: {0:<10} UNIT: {1:<10} TYPE: {2:<10} '
'GROUP: {3:<20} BINDING: {4}'
'\nAPPLIED TO: {5}\n'.format(p.Name,
str(p.UnitType),
str(p.ParameterType),
str(p.ParameterGroup),
bind,
[c.Name for c in b.Categories]))
output.print_md('## Project Parameters')
for pp in revit.query.get_project_parameters():
if not pp.shared:
output.print_md('#### {}'.format(pp.name))
print('\tUNIT: {}\n\tTYPE: {}\n\tGROUP: {}'
'\n\tBINDING: {}\n\tAPPLIED TO: {}\n'.format(
pp.unit_type,
pp.param_type,
pp.param_group,
pp.param_binding_type,
[x.Name for x in pp.param_binding.Categories]
))

output.print_md('# Shared Parameters')
for pp in revit.query.get_project_parameters():
if pp.shared:
output.print_md('#### {} : {}'.format(pp.name, pp.param_guid))
print('\tUNIT: {}\n\tTYPE: {}\n\tGROUP: {}'
'\n\tBINDING: {}\n\tAPPLIED TO: {}\n'.format(
pp.unit_type,
pp.param_type,
pp.param_group,
pp.param_binding_type,
[x.Name for x in pp.param_binding.Categories]
))

elif selected_switch == 'Unused Shared Parameters':
shared_params = \
set([x.Name + ':' + x.GUID.ToString()
for x in revit.query.get_defined_sharedparams()])
project_params = \
set([x.name + ':' + x.param_guid
for x in revit.query.get_project_parameters() if x.shared])
for unused_shared_param in shared_params - project_params:
print(unused_shared_param)

elif selected_switch == 'Data Schemas':
for sc in DB.ExtensibleStorage.Schema.ListSchemas():
Expand Down
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="&gt;&gt;&gt; Top" Click="move_to_top">
<Button.LayoutTransform>
<RotateTransform Angle="-90" />
</Button.LayoutTransform>
</Button>
<Button Grid.Row="1" Margin="0,0,0,5" Content="10 &gt;&gt;" Click="move_10_to_top">
<Button.LayoutTransform>
<RotateTransform Angle="-90" />
</Button.LayoutTransform>
</Button>
<Button Grid.Row="2" Margin="0,0,0,5" Content="&gt;" Click="move_1_to_top">
<Button.LayoutTransform>
<RotateTransform Angle="-90" />
</Button.LayoutTransform>
</Button>
<Button Grid.Row="3" Margin="0,0,0,5" Content="&lt;" Click="move_1_to_bottom">
<Button.LayoutTransform>
<RotateTransform Angle="-90" />
</Button.LayoutTransform>
</Button>
<Button Grid.Row="4" Margin="0,0,0,5" Content="10 &lt;&lt;" Click="move_10_to_bottom">
<Button.LayoutTransform>
<RotateTransform Angle="-90" />
</Button.LayoutTransform>
</Button>
<Button Grid.Row="5" Margin="0,0,0,0" Content="Bottom &lt;&lt;&lt;" 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>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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()
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Set Crop Region To Selected Shape
Open Selected Viewport
View Ordering Tool
-----
ReOrder Sheets
Decrement Selected Sheet Numbers
Increment Selected Sheet Numbers
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
# place lines on active view
try:
with revit.Transaction('Place Origin Marker', log_errors=False):
revit.doc.Create.NewDetailCurve(revit.activeview, line1)
revit.doc.Create.NewDetailCurve(revit.activeview, line2)
if revit.doc.IsFamilyDocument:
revit.doc.FamilyCreate.NewDetailCurve(revit.activeview, line1)
revit.doc.FamilyCreate.NewDetailCurve(revit.activeview, line2)
else:
revit.doc.Create.NewDetailCurve(revit.activeview, line1)
revit.doc.Create.NewDetailCurve(revit.activeview, line2)
except Exception as ex:
forms.alert("You are not on a plan view.", sub_msg=str(ex))
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

all_options = list(element_types)
all_options.extend(graphic_styles)
all_options.extend(['Fill Patterns'])
all_options.extend(['Fill Patterns', 'Area Schemes'])
selected_option = \
forms.CommandSwitchWindow.show(all_options,
message='Pick type category:')
Expand All @@ -33,6 +33,10 @@
fill_patterns = revit.query.get_types_by_class(DB.FillPatternElement,
doc=revit.doc)
selection.set_to(list(fill_patterns))
if selected_option == 'Area Schemes':
area_schemes = revit.query.get_types_by_class(DB.AreaScheme,
doc=revit.doc)
selection.set_to(list(area_schemes))
elif selected_option.startswith('Graphics Styles: '):
graphic_style_cat = selected_option.replace('Graphics Styles: ', '')
graphic_styles = \
Expand Down
Loading

0 comments on commit 58cc1ad

Please sign in to comment.