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 14, 2018
2 parents 534fb80 + a740e52 commit bf45832
Show file tree
Hide file tree
Showing 48 changed files with 1,054 additions and 306 deletions.
5 changes: 5 additions & 0 deletions dev/WPFEdit/WPFEdit/WPFEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\..\..\extensions\pyRevitTools.extension\pyRevit.tab\Modify.panel\Match.pushbutton\MatchConfigWindowLegacy.xaml">
<Link>Tools\MatchConfigWindowLegacy.xaml</Link>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="..\..\..\extensions\pyRevitTools.extension\pyRevit.tab\Modify.panel\Patterns.splitpushbutton\Make Pattern.pushbutton\MakePatternWindow.xaml">
<Link>Tools\MakePatternWindow.xaml</Link>
<Generator>MSBuild:Compile</Generator>
Expand Down
3 changes: 3 additions & 0 deletions dev/todo.todo
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ pyrevit cli:
installer:

pyrevit:
☐ fix log messages in tools
☐ faster sheet titleblock selection tool
☐ the help uri for splitpushbutton doesn't work correctly e.g match tool
☐ slowly move collectors in List tool to db.query
☐ slowly phase out the extpackages module and user PyRevitLabs
1 change: 1 addition & 0 deletions extensions/pyRevitCore.extension/pyRevit.tab/_layout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyRevit[beforeall:]
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<StackPanel>
<WrapPanel Margin="10,15,0,5">
<ToggleButton Style="{StaticResource AnimatedSwitch}" Height="24" x:Name="rocketmode_cb" IsChecked="False"/>
<TextBlock Margin="30,4,0,0">Rocket Mode &#x1F680; (Experimental / Reload Required)</TextBlock>
<TextBlock Margin="30,4,0,0">Rocket Mode &#x1F680; (Reload Required)</TextBlock>
</WrapPanel>
<TextBlock TextWrapping="WrapWithOverflow" Margin="65,0,10,10">This is the switch for pyRevit Rocket Mode.
If enabled, pyRevit will use a shared engine per each extension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
__doc__ = 'Print the full path to the central model (if model is workshared).'
"""Print the full path to the central model (if model is workshared)."""


from pyrevit import revit, DB, UI
#pylint: disable=E0401
from pyrevit import revit
from pyrevit import forms


if revit.doc.IsWorkshared:
model_path = revit.doc.GetWorksharingCentralModelPath()
print(DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(model_path))
else:
forms.alert('Model is not workshared.')
forms.check_workshared(doc=revit.doc)
4 changes: 4 additions & 0 deletions extensions/pyRevitTools.extension/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
"url": "https://github.com/eirannejad/pyRevit.git",
"website": "http://eirannejad.github.io/pyRevit/",
"image": "",
"templates": {
"author": "Ehsan Iran-Nejad",
"docpath": "https://www.youtube.com/watch?v="
},
"dependencies": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


__context__ = 'selection'
__helpurl__ = 'https://www.youtube.com/watch?v=4IlvCkoOolw'
__helpurl__ = '{{docpath}}4IlvCkoOolw'
__doc__ = 'Lists all the elements that are tied to the selected element.'\
' For example elements tags or dimensions.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def process_sets(element_list):
el_sets[el.LineStyle.Name].append(el)
else:
eltype = revit.doc.GetElement(el.GetTypeId())
wrapped_eltype = revit.ElementWrapper(eltype)
el_sets[wrapped_eltype.name].append(el)
if eltype:
wrapped_eltype = revit.ElementWrapper(eltype)
el_sets[wrapped_eltype.name].append(el)

return el_sets

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ def show_placeholders(self):
def include_placeholders(self):
return self.indexspace_cb.IsChecked

@property
def sheet_list(self):
return self.sheets_lb.ItemsSource

@sheet_list.setter
def sheet_list(self, value):
self.sheets_lb.ItemsSource = value

@property
def printable_sheets(self):
return [x for x in self.sheet_list if x.printable]

def _get_schedule_text_data(self, schedule_view):
schedule_data_file = \
script.get_instance_data_file(str(schedule_view.Id.IntegerValue))
Expand All @@ -112,8 +124,8 @@ def _get_schedule_text_data(self, schedule_view):
as sched_data_file:
return sched_data_file.readlines()
except Exception as open_err:
logger.error('Error opening sheet index export: {} | {}'
.format(schedule_data_file, open_err))
logger.error('Error opening sheet index export: %s | %s',
schedule_data_file, open_err)
return sched_data

def _order_sheets_by_schedule_data(self, schedule_view, sheet_list):
Expand All @@ -126,13 +138,12 @@ def _order_sheets_by_schedule_data(self, schedule_view, sheet_list):
for sheet in sheet_list:
for line_no, data_line in enumerate(sched_data):
try:
if sheet.CanBePrinted:
if sheet.SheetNumber in data_line:
ordered_sheets_dict[line_no] = sheet
break
else:
logger.warning('Sheet {} is not printable.'
.format(sheet.SheetNumber))
if sheet.SheetNumber in data_line:
ordered_sheets_dict[line_no] = sheet
break
if not sheet.CanBePrinted:
logger.debug('Sheet %s is not printable.',
sheet.SheetNumber)
except Exception:
continue

Expand Down Expand Up @@ -166,7 +177,7 @@ def _get_printmanager(self):
except Exception as printerr:
logger.critical('Error getting printer manager from document. '
'Most probably there is not a printer defined '
'on your system. | {}'.format(printerr))
'on your system. | %s', printerr)
return None

def _print_combined_sheets_in_order(self):
Expand All @@ -182,11 +193,13 @@ def _print_combined_sheets_in_order(self):
sheet_set = DB.ViewSet()
original_sheetnums = []
with revit.Transaction('Fix Sheet Numbers') as t:
for idx, sheet in enumerate(self.sheets_lb.ItemsSource):
sht = sheet.revit_sheet
original_sheetnums.append(sht.SheetNumber)
sht.SheetNumber = NPC * (idx + 1) + sht.SheetNumber
sheet_set.Insert(sht)
for idx, sheet in enumerate(self.sheet_list):
rvtsheet = sheet.revit_sheet
original_sheetnums.append(rvtsheet.SheetNumber)
rvtsheet.SheetNumber = \
NPC * (idx + 1) + rvtsheet.SheetNumber
if sheet.printable:
sheet_set.Insert(rvtsheet)

# Collect existing sheet sets
cl = DB.FilteredElementCollector(revit.doc)
Expand Down Expand Up @@ -222,7 +235,7 @@ def _print_combined_sheets_in_order(self):
logger.critical(
'Error setting sheet set on print mechanism. '
'These items are included in the viewset '
'object:\n{}'.format(sheet_report)
'object:\n%s', sheet_report
)
raise viewset_err

Expand All @@ -241,10 +254,10 @@ def _print_combined_sheets_in_order(self):

# now fix the sheet names
with revit.Transaction('Restore Sheet Numbers') as t:
for sheet, sheetnum in zip(self.sheets_lb.ItemsSource,
for sheet, sheetnum in zip(self.sheet_list,
original_sheetnums):
sht = sheet.revit_sheet
sht.SheetNumber = sheetnum
rvtsheet = sheet.revit_sheet
rvtsheet.SheetNumber = sheetnum

def _print_sheets_in_order(self):
# make sure we can access the print config
Expand All @@ -254,7 +267,7 @@ def _print_sheets_in_order(self):
print_mgr.PrintToFile = True
# print_mgr.CombinedFile = False
print_mgr.PrintRange = DB.PrintRange.Current
for sheet in self.sheets_lb.ItemsSource:
for sheet in self.sheet_list:
output_fname = \
coreutils.cleanup_filename('{:05} {} - {}.pdf'
.format(sheet.print_index,
Expand All @@ -265,8 +278,8 @@ def _print_sheets_in_order(self):
if sheet.printable:
print_mgr.SubmitPrint(sheet.revit_sheet)
else:
logger.warning('Sheet {} is not printable. Skipping print.'
.format(sheet.SheetNumber))
logger.debug('Sheet %s is not printable. Skipping print.',
sheet.number)

def _update_print_indices(self, sheet_list):
for idx, sheet in enumerate(sheet_list):
Expand Down Expand Up @@ -295,20 +308,20 @@ def selection_changed(self, sender, args):
if not self.include_placeholders:
self._update_print_indices(printable_sheets)

self.sheets_lb.ItemsSource = printable_sheets
self.sheet_list = printable_sheets

else:
self.indexspace_cb.IsChecked = True
self.indexspace_cb.IsEnabled = False
# update print indices
self._update_print_indices(sheet_list)
# Show all sheets
self.sheets_lb.ItemsSource = sheet_list
self.sheet_list = sheet_list

def print_sheets(self, sender, args):
if self.sheets_lb.ItemsSource:
if self.sheet_list:
if not self.combine_print:
sheet_count = len(self.sheets_lb.ItemsSource)
sheet_count = len(self.sheet_list)
if sheet_count > 5:
if not forms.alert('Are you sure you want to print {} '
'sheets individually? The process can '
Expand Down Expand Up @@ -340,7 +353,7 @@ def drop_sheet(self, sender, args):
dropped_idx = self.sheets_lb.Items.IndexOf(dropped_data)
target_idx = self.sheets_lb.Items.IndexOf(target)

sheet_list = self.sheets_lb.ItemsSource
sheet_list = self.sheet_list
sheet_list.remove(dropped_data)
sheet_list.insert(target_idx, dropped_data)
self._update_print_indices(sheet_list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pyrevit import forms


__author__ = '{{author}}'
__doc__ = 'Select a revision from the list of revisions and this script '\
'will create a print sheet set for the revised sheets under the '\
'selected revision, and will assign the new sheet set as '\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyrevit import script


__helpurl__ = "https://www.youtube.com/watch?v=SJzs9ZxqRYc"
__helpurl__ = "{{docpath}}SJzs9ZxqRYc"

__doc__ = 'Enter sheet names and numbers in the text box and '\
'this tool will create all at once.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from Autodesk.Revit.DB import Element as DBElement


__helpurl__ = 'https://www.youtube.com/watch?v=9Q-J6mWBYJI&t=17s'
__helpurl__ = '{{docpath}}9Q-J6mWBYJI&t=17s'
__doc__ = 'Copies selected or current sheet(s) to other ' \
'projects currently open in Revit. Make sure the destination ' \
'documents have at least one Legend view (Revit API does not ' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyrevit import forms


__helpurl__ = 'https://www.youtube.com/watch?v=ThzcRM_Tj8g'
__helpurl__ = '{{docpath}}ThzcRM_Tj8g'
__doc__ = 'Converts selected legend views to detail views and copies '\
'them to all projects currently open in Revit.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyrevit import forms


__helpurl__ = 'https://www.youtube.com/watch?v=ThzcRM_Tj8g'
__helpurl__ = '{{docpath}}ThzcRM_Tj8g'


class CopyUseDestination(DB.IDuplicateTypeNamesHandler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pyrevit import script


logger = script.get_logger()
output = script.get_output()


Expand All @@ -30,12 +31,12 @@

class ReferencingView:
def __init__(self, view_id):
self.element = doc.GetElement(view_id)
self.element = revit.doc.GetElement(view_id)
if not self._valid_view():
raise Exception()

title = self.element.LookupParameter('Title on Sheet').AsString()
self.name = title if title else self.element.ViewName
titleos = self.element.LookupParameter('Title on Sheet').AsString()
self.name = titleos if titleos else self.element.ViewName
self.refs = []
self._update_refs(all_ref_els)
# self._update_refs(self.element.GetReferenceCallouts())
Expand All @@ -59,9 +60,12 @@ def _valid_view(self):

def _update_refs(self, el_list):
for elid in el_list:
el = doc.GetElement(elid)
if el.OwnerViewId == self.element.Id:
self.refs.append(el.Name)
element = revit.doc.GetElement(elid)
viewnameparam = element.LookupParameter("View Name")
if element.OwnerViewId == self.element.Id \
or (viewnameparam \
and viewnameparam.AsString() == self.element.ViewName):
self.refs.append(element.Name)

def is_referring_to(self, view_name):
return view_name in self.refs
Expand All @@ -76,14 +80,13 @@ def is_sheeted(self):
try:
rv = ReferencingView(view.Id)
all_views.append(rv)
except Exception:
pass
except Exception as ex:
logger.debug(ex)


print('{} views processed...'.format(len(all_views)))

for selid in selection:
vp = revit.doc.GetElement(selid)
for vp in selection:
if isinstance(vp, DB.Viewport):
v = revit.doc.GetElement(vp.ViewId)
title = v.LookupParameter('Title on Sheet').AsString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ def name(self):

if not unusedFilters:
forms.alert('All filters are in use. No purging in necessary.')

# ask user for wipe actions
return_options = \
forms.SelectFromList.show(
[ViewFilterToPurge(revit.doc.GetElement(DB.ElementId(x)))
for x in unusedFilters],
title='Select Filters to Purge',
width=500,
button_name='Purge Filters',
multiselect=True
)

# print('{} Filters have not been used and will be purged.'
# .format(len(unusedFilters)))

if return_options:
with revit.Transaction('Purge Unused Filters'):
for vf in return_options:
logger.debug('Purging Filter: {0}\t{1}'
.format(vf.Id, vf.Name))
try:
revit.doc.Delete(vf.Id)
except Exception as del_err:
logger.error('Error purging filter: {} | {}'
.format(vf.Name, del_err))
else:
# ask user for wipe actions
return_options = \
forms.SelectFromList.show(
[ViewFilterToPurge(revit.doc.GetElement(DB.ElementId(x)))
for x in unusedFilters],
title='Select Filters to Purge',
width=500,
button_name='Purge Filters',
multiselect=True
)

# print('{} Filters have not been used and will be purged.'
# .format(len(unusedFilters)))

if return_options:
with revit.Transaction('Purge Unused Filters'):
for vf in return_options:
logger.debug('Purging Filter: {0}\t{1}'
.format(vf.Id, vf.Name))
try:
revit.doc.Delete(vf.Id)
except Exception as del_err:
logger.error('Error purging filter: {} | {}'
.format(vf.Name, del_err))
Loading

0 comments on commit bf45832

Please sign in to comment.