Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handled rvt links not loaded + not displyaing warnings section when no warning #1140

Merged
merged 19 commits into from
Jan 25, 2021
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 147 additions & 112 deletions extensions/pyRevitTools.extension/checks/modelchecker_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,18 @@ def checkModel(doc, output):
rvtlinks_id_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_RvtLinks)
.WhereElementIsNotElementType()
.ToElementIds()
.WhereElementIsElementType()
.ToElements()
)
rvtlinkdocs, rvtlinkdocsName = [], []
if not len(rvtlinks_id_collector):
pass
else:

if len(rvtlinks_id_collector):
revitLinksdoc = DB.FilteredElementCollector(doc).OfClass(DB.RevitLinkInstance)
for i in revitLinksdoc:
rvtlinkdocs.append(i.GetLinkDocument())
rvtlinkdocsName.append(i.GetLinkDocument().Title)
if i.GetLinkDocument():
rvtlinkdocsName.append(i.GetLinkDocument().Title)
else:
rvtlinkdocsName.append("Document not loaded")
rvtlinksCount = len(rvtlinks_id_collector)
# output.print_md(str(rvtlinksCount) +" Revit Links")

Expand All @@ -332,36 +333,13 @@ def checkModel(doc, output):
rvtlinksNames.append(x.Name)
rvtlinkspinnedCountTrue = sum(rvtlinkspinnedCount)
# print(str(rvtlinkspinnedCountTrue) +" Revit Links pinned")
else:
pass

### View collectors
# sheets
sheets_id_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Sheets)
.WhereElementIsNotElementType()
.ToElementIds()
)
sheetCount = len(sheets_id_collector)
# print(str(sheetCount)+" Sheets")

# schedules
schedules_id_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Schedules)
.WhereElementIsNotElementType()
.ToElements()
)
scheduleCount = 0
### scheduleNames = []
for schedule in schedules_id_collector:
if (
schedule.Name[:19] != "<Revision Schedule>"
# to support french files
or schedule.Name[:28] != "<Nomenclature des révisions>"
):
scheduleCount += 1
### scheduleNames.append((schedule.Name))
### output.print_md("<br />".join(scheduleNames))


# views
views_id_collector = (
DB.FilteredElementCollector(doc)
Expand Down Expand Up @@ -389,6 +367,16 @@ def checkModel(doc, output):
except:
pass

# sheets
sheets_id_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Sheets)
.WhereElementIsNotElementType()
.ToElementIds()
)
sheetCount = len(sheets_id_collector)
# print(str(sheetCount)+" Sheets")

sheets_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Sheets)
Expand All @@ -409,6 +397,36 @@ def checkModel(doc, output):
pass
viewsNotOnSheet = viewCount - len(viewsOnSheet)

# view Templates
views = DB.FilteredElementCollector(doc).OfClass(DB.View)
appliedTemplates = [v.ViewTemplateId for v in views]
viewTemplates = [v for v in views if v.IsTemplate == True]
unusedViewTemplates = []
for v in viewTemplates:
if v.Id not in appliedTemplates:
unusedViewTemplates.append(v.Name)
unusedViewTemplatesCount = (len(unusedViewTemplates))


# schedules
schedules_id_collector = (
DB.FilteredElementCollector(doc)
.OfCategory(DB.BuiltInCategory.OST_Schedules)
.WhereElementIsNotElementType()
.ToElements()
)
scheduleCount = 0
### scheduleNames = []
for schedule in schedules_id_collector:
if (
schedule.Name[:19] != "<Revision Schedule>"
# to support french files
or schedule.Name[:28] != "<Nomenclature des révisions>"
):
scheduleCount += 1
### scheduleNames.append((schedule.Name))
### output.print_md("<br />".join(scheduleNames))

# schedules not on sheets
schedulesOnSheet = []
ScheduleCollectorInstances = (
Expand Down Expand Up @@ -443,7 +461,6 @@ def checkModel(doc, output):
schedulesOnSheet.append(schedName)
scheduleNotOnSheet = scheduleCount - len(schedulesOnSheet)


# warnings
allWarnings_collector = doc.GetWarnings()
allWarningsCount = len(allWarnings_collector)
Expand Down Expand Up @@ -650,6 +667,9 @@ def DocPhases(doc, links = []):
viewTres = 500
viewNotOnSheetTres = viewCount * 0.2
copiedViewTres = viewCount * 0.2
# View Templates
viewTemplatesTres = 500
unusedViewTemplateTres = len(viewTemplates) * 0.2
# Sheets
sheetsTres = 500
# Schedules
Expand Down Expand Up @@ -701,6 +721,7 @@ def DocPhases(doc, links = []):

## RVT Links dashboard section
# print RVT links names
output.print_md("---")
output.print_md("# RVT Links")
if not len(rvtlinks_id_collector):
output.print_md("No links")
Expand All @@ -718,6 +739,7 @@ def DocPhases(doc, links = []):
)
dashboardLeftMaker(htmlRowRVTlinks)

output.print_md("---")
## Views dashboard section
# print Views section header
output.print_md("# Views")
Expand All @@ -736,6 +758,18 @@ def DocPhases(doc, links = []):
)
dashboardLeftMaker(htmlRowViews)

## ViewTemplates dashboard section
# print ViewTemplates section header
output.print_md("# View Templates")

# Make row
htmlRowViews = (
dashboardRectMaker(len(viewTemplates), "View Templates", viewTemplatesTres)
+ dashboardRectMaker(unusedViewTemplatesCount, "Unused View Templates", unusedViewTemplateTres)

)
dashboardLeftMaker(htmlRowViews)

## Schedule dashboard section
# print Schedules section header
output.print_md("# Schedules")
Expand Down Expand Up @@ -767,33 +801,36 @@ def DocPhases(doc, links = []):
# print Warnings section header
output.print_md("# Warnings")
# Make row
htmlRowWarnings = (
dashboardRectMaker(
allWarningsCount, "Warnings", warningsTres
)
+ dashboardRectMaker(
criticalWarningCount,
"Critical <br>Warnings",
criticalWarningsTres
if allWarningsCount != 0:
htmlRowWarnings = (
dashboardRectMaker(
allWarningsCount, "Warnings", warningsTres
)
+ dashboardRectMaker(
criticalWarningCount,
"Critical <br>Warnings",
criticalWarningsTres
)
)
)
dashboardLeftMaker(htmlRowWarnings)
# warnings count per type doughnut
chartWarnings = output.make_doughnut_chart()
chartWarnings.options.title = {
"display": True,
"text": "Warning Count by Type",
"fontSize": 25,
"fontColor": "#000",
"fontStyle": "bold",
"position": "left"
}
chartWarnings.options.legend = {"position": "top", "fullWidth": False}
chartWarnings.data.labels = [x.encode('UTF-8') for x in warnDescriptionHeadings]
set_w = chartWarnings.data.new_dataset("Not Standard")
set_w.data = warnSet
set_w.backgroundColor = COLORS
chartWarnings.draw()
dashboardLeftMaker(htmlRowWarnings)
# warnings count per type doughnut
chartWarnings = output.make_doughnut_chart()
chartWarnings.options.title = {
"display": True,
"text": "Warning Count by Type",
"fontSize": 25,
"fontColor": "#000",
"fontStyle": "bold",
"position": "left"
}
chartWarnings.options.legend = {"position": "top", "fullWidth": False}
chartWarnings.data.labels = [x.encode('UTF-8') for x in warnDescriptionHeadings]
set_w = chartWarnings.data.new_dataset("Not Standard")
set_w.data = warnSet
set_w.backgroundColor = COLORS
chartWarnings.draw()
else:
output.print_md("No warnings, good job!")

## Materials dashboard section
# print Materials section header
Expand Down Expand Up @@ -855,6 +892,48 @@ def DocPhases(doc, links = []):
)
dashboardLeftMaker(htmlRowLoadableFamilies)

if inPlaceFamilyCount != 0:
# INPLACE CATEGORY GRAPH
fCatSet = []
# sorting results in chart legend
graphFCatHeadings.sort()
for i in graphFCatHeadings:
count = graphFCatData.count(i)
fCatSet.append(count)

graphFCatData = [x.encode("utf8") for x in graphFCatData]
graphFCatHeadings = [x.encode("utf8") for x in graphFCatHeadings]

# categories OUTPUT
chartFCategories = output.make_doughnut_chart()
chartFCategories.options.title = {
"display": True,
"text": "InPlace Family Count by Category",
"fontSize": 25,
"fontColor": "#000",
"fontStyle": "bold",
"position": "left"
}
chartFCategories.data.labels = graphFCatHeadings
set_a = chartFCategories.data.new_dataset("Not Standard")
set_a.data = fCatSet

set_a.backgroundColor = COLORS
# chartFCategories.randomize_colors()
# scaling graph according to categories count - size of graph is
# measured with legend which can be quite complex
catFCount = len(graphFCatHeadings)
if catFCount < 15:
chartFCategories.set_height(100)
elif catFCount < 30:
chartFCategories.set_height(160)
else:
chartFCategories.set_height(200)

chartFCategories.draw()
else:
pass

## Text Notes dashboard section
# print Text Notes section header
output.print_md("# Text Notes")
Expand Down Expand Up @@ -932,6 +1011,13 @@ def DocPhases(doc, links = []):
)
dashboardLeftMaker(htmlRowRefPlanes)

## Phases dashboard section
# print Phases section header
output.print_md("# Phases\n")
rvtlinkdocsName.insert(0,printedName)
filePhases = rvtlinkdocsName,[','.join(i) for i in phase]
output.print_table(zip(*filePhases), columns=["File Name","Phases"], formats=None, title='', last_line_style='')

## Elements count dashboard section
# print Elements count section header
output.print_md("# Elements count")
Expand All @@ -943,14 +1029,6 @@ def DocPhases(doc, links = []):
)
dashboardLeftMaker(htmlRowElementsCount)

## Phases dashboard section
# print Phases section header
output.print_md("# Phases\n")
rvtlinkdocsName.insert(0,printedName)
filePhases = rvtlinkdocsName,[','.join(i) for i in phase]
output.print_table(zip(*filePhases), columns=["File Name","Phases"], formats=None, title='', last_line_style='')


# divider
print("\n\n\n\n")

Expand Down Expand Up @@ -1098,49 +1176,6 @@ def DocPhases(doc, links = []):

chartWorksets.draw()

# divider
print("\n\n\n\n")

# INPLACE CATEGORY GRAPH
fCatSet = []
# sorting results in chart legend
graphFCatHeadings.sort()
for i in graphFCatHeadings:
count = graphFCatData.count(i)
fCatSet.append(count)

graphFCatData = [x.encode("utf8") for x in graphFCatData]
graphFCatHeadings = [x.encode("utf8") for x in graphFCatHeadings]

# categories OUTPUT
chartFCategories = output.make_doughnut_chart()
chartFCategories.options.title = {
"display": True,
"text": "InPlace Family Count by Category",
"fontSize": 25,
"fontColor": "#000",
"fontStyle": "bold",
}
chartFCategories.data.labels = graphFCatHeadings
set_a = chartFCategories.data.new_dataset("Not Standard")
set_a.data = fCatSet

set_a.backgroundColor = COLORS
# chartFCategories.randomize_colors()
# scaling graph according to categories count - size of graph is
# measured with legend which can be quite complex
catFCount = len(graphFCatHeadings)
if catFCount < 15:
chartFCategories.set_height(100)
elif catFCount < 30:
chartFCategories.set_height(160)
else:
chartFCategories.set_height(200)

chartFCategories.draw()



class ModelChecker(PreflightTestCase):
"""
Revit model quality check
Expand Down