Skip to content

Commit

Permalink
Merge branch 'release/4.6.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Mar 2, 2019
2 parents ea8a878 + 71c7b72 commit 931282c
Show file tree
Hide file tree
Showing 27 changed files with 4,488 additions and 105 deletions.
21 changes: 11 additions & 10 deletions extensions/pyRevitDevTools.extension/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@
errors are printed from pyRevit commands.
"""

# with open(r'C:\Temp\test.txt', 'w') as f:
# f.write('test')
import sys

# add your module paths to the sys.path here
# sys.path.append(r'path/to/your/module')

print('Startup script execution test.')
print('\n'.join(sys.path))


# # importing HOST_APP to access Autodesk.Revit.ApplicationServices.Application
# example code for creating event handlers
# from pyrevit import HOST_APP, framework
# from pyrevit import DB
# from pyrevit import forms
#
#
# # define event handler

# define event handler
# def docopen_eventhandler(sender, args):
# forms.alert('Document Opened: {}'.format(args.PathName))
#
#
# # add to DocumentOpening
# # type is EventHandler[DocumentOpeningEventArgs] so create that correctly

# add to DocumentOpening
# type is EventHandler[DocumentOpeningEventArgs] so create that correctly
# HOST_APP.app.DocumentOpening += \
# framework.EventHandler[DB.Events.DocumentOpeningEventArgs](
# docopen_eventhandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,25 @@
<DockPanel Margin="10">
<Grid DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="14" VerticalAlignment="Center">
Double-Click on a Cell to Specify the Change Type:
Double-Click on a Cell to Specify the Change Type
</TextBlock>
<DockPanel Grid.Column="1">
<WrapPanel x:Name="sheetordering_options" Visibility="Collapsed" IsEnabled="False">
<TextBlock Text="Sheet Ordering" VerticalAlignment="Center" />
<ComboBox x:Name="orderparams_cb" Width="200" Height="24" Margin="5,0,10,0" SelectionChanged="update_list"/>
</WrapPanel>
<ContentControl Content="{StaticResource filterIcon}" Width="24" Height="24" Margin="5,0,10,0">
<ContentControl.LayoutTransform>
<ScaleTransform ScaleX="0.4" ScaleY="0.4"/>
</ContentControl.LayoutTransform>
</ContentControl>
<StackPanel>
<TextBox x:Name="search_tb" Height="25px" Padding="5,0,24,0"
TextChanged="search_txt_changed" VerticalContentAlignment="Center"/>
TextChanged="update_list" VerticalContentAlignment="Center"/>
<Button x:Name="clrsearch_b" Visibility="Collapsed" Margin="0,-25,2,0" Padding="0,-4,0,0"
Width="22px" Height="22px" HorizontalAlignment="Right"
BorderThickness="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def __getattr__(self, attr_name):

return citem

def __repr__(self):
return '<{} no:{}>'.format(self.__class__.__name__, self.number)

@property
def name(self):
return self._csheet.name
Expand All @@ -147,6 +150,9 @@ def build_commit_param(commit_point):
def build_commit_sort_param(commit_point):
return 'sort_{}{}'.format(commit_point.cptype, commit_point.idx)

def get_order(self, param_name):
return self._csheet.revit_sheet.LookupParameter(param_name).AsInteger()

def get_commit_at_point(self, commit_point):
return self._csheet.get_commit_at_point(commit_point)

Expand Down Expand Up @@ -176,6 +182,9 @@ def __init__(self, xaml_file_name):

forms.WPFWindow.__init__(self, xaml_file_name)

# prepare default privates
self._last_filter_len = 0

# prepare wpf resources
self.dt_template = None
self.package_column_cell_style = \
Expand Down Expand Up @@ -203,14 +212,13 @@ def __init__(self, xaml_file_name):
sheetitems = [SheetItem(x) for x in committed_sheets]

self._sheetitems = sorted(sheetitems, key=lambda x: x.number)
self._setup_item_params_combobox(committed_sheets)

# list all sheets
self._list_sheets()
if isinstance(revit.activeview, DB.ViewSheet):
self.search_tb.Text = revit.activeview.SheetNumber

self.last_selected_number = ''

def _read_resources(self):
dt_template_file = script.get_bundle_file('PackagesDataTemplate.xaml')
with open(dt_template_file, 'r') as dt_file:
Expand Down Expand Up @@ -240,15 +248,30 @@ def _build_columns(self):

def _list_sheets(self, sheet_filter=None):
if not self.sheets_dg.ItemsSource or not sheet_filter:
self.sheets_dg.ItemsSource = list(self._sheetitems)
items_source = list(self._sheetitems)
else:
items_source = self.sheets_dg.ItemsSource

if sheet_filter:
sheet_filter = sheet_filter.lower()
self.sheets_dg.ItemsSource = \
[x for x in self.sheets_dg.ItemsSource
sheet_filter_len = len(sheet_filter)
# if backspacing, reset the sheet list
if self._last_filter_len > sheet_filter_len:
items_source = list(self._sheetitems)

items_source = \
[x for x in items_source
if sheet_filter in x.number.lower()
or sheet_filter in x.name.lower()]

self._last_filter_len = sheet_filter_len

if self.sheetorder_param:
param = self.sheetorder_param
items_source = \
sorted(items_source, key=lambda x: x.get_order(param))

self.sheets_dg.ItemsSource = items_source
# update misc gui items
if len(self.sheets_dg.ItemsSource) > 1:
self.updatesheets_b.Content = "Update Sheets"
Expand Down Expand Up @@ -288,7 +311,25 @@ def _ask_for_commit_type(self, sheet_item, commit_pt, commit):
else:
forms.alert('No changes is allowed at this point.')

def search_txt_changed(self, sender, args):
def _setup_item_params_combobox(self, committed_sheets):
if committed_sheets:
csheet = committed_sheets[0]
sheet_params = \
[x.Definition.Name for x in csheet.revit_sheet.Parameters
if x.StorageType == DB.StorageType.Integer]
order_params = [x for x in sheet_params if 'order' in x.lower()]
if order_params:
self.orderparams_cb.ItemsSource = sorted(order_params)
self.orderparams_cb.SelectedIndex = 0
self.sheetordering_options.IsEnabled = True
self.show_element(self.sheetordering_options)

@property
def sheetorder_param(self):
if self.sheetordering_options.IsEnabled:
return self.orderparams_cb.SelectedItem

def update_list(self, sender, args):
"""Handle text change in search box."""
if self.search_tb.Text == '':
self.hide_element(self.clrsearch_b)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Lists all views that the selected elements is visible in."""
#pylint: disable=import-error,invalid-name
from pyrevit import revit, DB
from pyrevit import script


__context__ = 'selection'


selection = revit.get_selection()
output = script.get_output()


# collect all model views
cl_views = DB.FilteredElementCollector(revit.doc)
allviews = cl_views.OfCategory(DB.BuiltInCategory.OST_Views)\
.WhereElementIsNotElementType()\
Expand All @@ -18,29 +20,27 @@
and not x.IsTemplate),
allviews)

viewList = []

# process visible elements in views
view_list = []

for v in views:
print('Searching {0} of type: {1}'.format(revit.query.get_name(v),
str(v.ViewType).ljust(25)))
print('Searching {} of type: {}'
.format(revit.query.get_name(v), str(v.ViewType).ljust(25)))

# collect view elements
cl_els = DB.FilteredElementCollector(revit.doc, v.Id)\
.WhereElementIsNotElementType()\
.ToElementIds()

print('\tTotal found: {0}'.format(len(cl_els)))

i = 0
for elId in selection:
if elId in cl_els:
for elid in revit.get_selection().element_ids:
if elid in cl_els:
i = + 1
viewList.append(v)
print('\t{0} element(s) found.'.format(i))
view_list.append(v)
print('\t{0} matching element(s) found.'.format(i))

print('\n\nViews Containing the selected objects:')
output.print_md('## Views Containing the selected objects:')

for v in viewList:
print('{0}{1}ID:{2}'.format(revit.query.get_name(v).ljust(45),
str(v.ViewType).ljust(25),
str(v.Id).ljust(10)))
for view in view_list:
revit.report.print_view(view)
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</Path>
</Canvas>

<Canvas x:Key="reserveIcon">
<Canvas x:Key="templatesIcon">
<Path Canvas.Top="-9" Canvas.Left="-8"
Data="M3,3H21V7H3V3M4,8H20V21H4V8M9.5,11A0.5,0.5 0 0,0 9,11.5V13H15V11.5A0.5,0.5 0 0,0 14.5,11H9.5Z"
Data="M20,6H12L10,4H4A2,2 0 0,0 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8A2,2 0 0,0 20,6M15,16H6V14H15V16M18,12H6V10H18V12Z"
Fill="Black">
<Path.LayoutTransform>
<ScaleTransform ScaleX="0.7" ScaleY="0.7" />
Expand Down Expand Up @@ -77,8 +77,7 @@
<Button Height="24" Content="Ti" Margin="0,5,0,0" FontWeight="Medium" ToolTip="To Title Case" Click="to_title"/>
<Button Height="24" Content="Se" Margin="0,5,0,0" FontWeight="Medium" ToolTip="To Sentence case" Click="to_sentence"/>
<Button Height="24" Content="{StaticResource translateIcon}" Margin="0,5,0,0" ToolTip="Translate" Click="translate"/>
<Button Height="24" Content="{StaticResource reserveIcon}" Margin="0,5,0,0" FontWeight="Medium" ToolTip="Change text to RESERVED" Click="to_reserved"/>
<Button Height="24" Content="{StaticResource donotuseIcon}" Margin="0,5,0,0" FontWeight="Medium" ToolTip="Add DO NOT USE to text" Click="to_donotuse"/>
<Button Height="24" Content="{StaticResource templatesIcon}" Margin="0,5,0,0" FontWeight="Medium" ToolTip="Templates" Click="select_template"/>
</StackPanel>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</Style>

<Canvas x:Key="filterIcon">
<Path Canvas.Top="-16" Canvas.Left="-15"
<Path Canvas.Top="-14" Canvas.Left="-14"
Data="F1 M 45.4403,56.9637L 45.4403,55.0463L 52.8201,44.5143L 52.8201,44.4237L 46.13,44.4237L 46.13,41.4774L 57.372,41.4774L 57.372,43.5352L 50.1532,53.9265L 50.1532,54.0174L 57.4869,54.0174L 57.4869,56.9637L 45.4403,56.9637 Z M 34.8333,61.75L 34.8333,42.75L 19,20.5833L 57,20.5833L 41.1667,42.75L 41.1667,58.5833L 34.8333,61.75 Z M 25.903,52.8055L 21.4072,52.8055L 20.289,56.9855L 16.6085,56.9855L 21.4072,41.4556L 26.0661,41.4556L 30.9337,56.9855L 27.1143,56.9855L 25.903,52.8055 Z M 21.9196,50.2801L 25.3905,50.2801L 24.4122,46.9804L 23.9987,45.4806L 23.6201,43.981L 23.5736,43.981L 23.2212,45.4941L 22.8514,47.0194L 21.9196,50.2801 Z "
Fill="Black">
<Path.LayoutTransform>
<ScaleTransform ScaleX="0.4" ScaleY="0.4"/>
<ScaleTransform ScaleX="0.36" ScaleY="0.36"/>
</Path.LayoutTransform>
</Path>
</Canvas>
Expand Down Expand Up @@ -169,10 +169,12 @@
<TextBlock Text="{Binding Path=key}" Grid.Column="0" FontWeight="Medium"/>
<WrapPanel Grid.Column="1" >
<TextBlock Text="{Binding Path=text}" Margin="10,0,0,0" Padding="0" TextWrapping="Wrap" />
<Border x:Name="usedCount" Background="LightGray" Height="16" CornerRadius="4" Margin="10,0,0,0" Padding="5,0,5,0" Visibility="Collapsed">
<Border x:Name="usedCount"
Background="White" BorderBrush="LightGray" BorderThickness="1"
Height="16" CornerRadius="4" Margin="10,0,0,0" Padding="8,0,8,0" Visibility="Collapsed" ToolTip="{Binding Path=tooltip}">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="DimGray" FontSize="10">
<TextBlock.Text>
<MultiBinding StringFormat=" {0} refs">
<MultiBinding StringFormat="{}{0}x">
<Binding Path="used_count"/>
</MultiBinding>
</TextBlock.Text>
Expand Down Expand Up @@ -416,11 +418,15 @@
BorderThickness="1" BorderBrush="LightGray" />
</Grid>
</Grid>
<TextBlock Text="Double Click to Place:" Margin="0,10,0,0"/>
<ComboBox x:Name="keynotetype_cb" Margin="0,5,0,0" SelectedIndex="0" IsEditable="False" />
</StackPanel>
</GroupBox>

<GroupBox Header="Keynote Tags" Margin="0,10,0,0" Padding="5">
<StackPanel>
<RadioButton x:Name="userknote_rb" Content="User Keynotes" Margin="0,0,0,5"/>
<RadioButton x:Name="elementknote_rb" Content="Element Keynotes" Margin="0,0,0,5"/>
<RadioButton x:Name="materialknote_rb" Content="Material Keynotes" />
</StackPanel>
</GroupBox>
<GroupBox Header="Keynotes History" Margin="0,10,0,0" Padding="5">
<StackPanel >
<Button Content="Enable History"
Expand Down
Loading

0 comments on commit 931282c

Please sign in to comment.