π Preflight Checks Hackathon 2024 Link to heading
What is a preflight check in pyRevit? Link to heading
Preflight Checks are Python scripts processed through the Preflight Checks tool in the pyRevit toolbar.
It can take look like this:
Collect data from the actual documents or revit links, export the data collected for later use and comparison with historical data, …
The code for each check resides in the checks
folder of each pyRevit extension.
You can find examples in the Main Tools Extension.
On your computer, it is usually located at:
%appdata%\pyRevit-Master\extensions\pyRevitTools.extension\checks
Goal Link to heading
- Make people aware of the tool
- Make people use it
- Create badass preflight checks for the community
- Make it the one tool for QA QC, built by the community
- Modularize the checks
- Add more functionalities
- …
Conditions Link to heading
Who can enter? Link to heading
- Simple: Anyone! Even pyRevit enthusiasts and contributors can participate (though they will be excluded from the jury π€).
How to submit your entry? Link to heading
- Create a PR against the Preflight Checks Hackathon 2024 branch.
- Advanced users can create their own fork and submit a PR against the upstream one.
- Beginners can create a new check as follows:
If youβre unsure about the process, send your code to hello@pyrevitlab.io with your name, and weβll take care of it.
Show off your work on the forum in the Tools - Preflight Checks Hackathon Category.
Timeline Link to heading
β οΈ The deadline for submissions is November 1st, 2024.
Categories & Prizes Link to heading
All relevant entries will be added to the official pyRevit preflight checks.
π€© Keep It Simple - $25 Gift Card or Equivalent
A check that is both simple and smart.
π» Code Elegance - $50 Gift Card or Equivalent
Code that is either artistically elegant or highly Pythonic.
π Most Advanced - $100 Gift Card or Equivalent
A complete check that pushes the boundaries of quality control.
π§βππ»β Best of the Best - $200 Gift Card or Equivalent
Simple, elegant, advanced, and maybe even smarter than the othersβthis entry might include a library that makes the check more reusable. Code improvements to the Preflight Checks Tools are also welcome.
Jury Link to heading
- Ehsan, Jean-Marc, AndreaG, and Dosymep, plus others willing to participate in the evaluation process.
How to create a preflight check? Link to heading
- Understand the structure; see the explanation below.
- Use the template.
- Try to use charts to make your data look good.
Structure Link to heading
- Boilerplate
- Document declaration
- Definitions of all the data you are collecting in the Revit models
- Main definition calling all the previous ones, organizing the data, and making the output look good
- Class with pre- and post-definitions in case you need to clean up after the preflight checks
- It contains the description of what your preflight check does
- Its title
- Its author
- The
startTest
method that calls thecheck_model
definition
Template Link to heading
The file needs to be named: relevantName-**check.py**
, with the last part being the most important, as the parser looks for check.py
in the folder.
Boilerplate
# -*- coding: UTF-8 -*-
from pyrevit import script, revit, DB, DOCS
from pyrevit.preflight import PreflightTestCase
doc = DOCS.doc
π¦ Here, each definition collects info about specific Revit elements. Sample definitions to collect data about grids π
def grids_collector(document):
grids = DB.FilteredElementCollector(document).OfCategory(DB.BuiltInCategory.OST_Grids).WhereElementIsNotElementType()
return grids
def grids_count(document=doc):
grids = grids_collector(document)
count = grids.GetElementCount()
return count
def grids_names(document=doc):
grids = grids_collector(document)
grids_names = []
for grid in grids:
grids_names.append(grid.Name)
return grids_names
def grids_types(document=doc):
grids = grids_collector(document)
grids_types = []
for grid in grids:
grid_type = document.GetElement(grid.GetTypeId())
# grid_type = grid.get_Parameter(DB.BuiltInParameter.ELEM_TYPE_PARAM).AsElement()
grids_types.append(grid_type.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString())
return grids_types
def grids_pinned(document=doc):
grids = grids_collector(document)
pinned_grids = []
for grid in grids:
pinned_grids.append(grid.Pinned)
return pinned_grids
def grids_scoped(document=doc):
grids = grids_collector(document)
scoped_grids = []
for grid in grids:
scope = grid.get_Parameter(DB.BuiltInParameter.DATUM_VOLUME_OF_INTEREST).AsElementId()
scope = document.GetElement(scope)
if scope:
scoped_grids.append(scope.Name)
else:
scoped_grids.append("None")
return scoped_grids
Main definition where elements data is organized and where you make it look good
def check_model(doc, output):
output = script.get_output()
output.close_others()
output.print_md("# Grids Data Lister")
count = grids_count()
output.print_md("## Number of grids: {0}".format(count))
names = grids_names() # [1,2,3,4]
types = grids_types() # [bubble, bubble, bubble, bubble]
pinned = grids_pinned() # [True, False, True, False]
scoper = grids_scoped() # [Name of scope, Name of scope, Name of scope, Name of scope]
# π¦ Here, we output the data in a table but you could use the charts modules to get better looking dashboard like in the https://github.com/pyrevitlabs/pyRevit/blob/Preflight-Checks_Hackathon_2024/extensions/pyRevitTools.extension/checks/modelchecker_check.py
output.print_table(table_data=zip(names, types, pinned, scoper), title="Grids", columns=["Name", "Type", "Pinned", "Scope Box"])
Main Class
class ModelChecker(PreflightTestCase):
#π¦ This will be your check's description in the preflight checks UI π
"""
List grids, if they are pinned, scoped boxed, or named
This QC tools returns you with the following data:
Grids count, name, type, pinned status
"""
#π¦ This will be your check's title in the preflight checks UI π
name = "Grids Data Lister"
author = "Jean-Marc Couffin"
def setUp(self, doc, output):
pass
def startTest(self, doc, output):
#π¦ This is where you call the check_model definition π
checkModel(doc, output)
def tearDown(self, doc, output):
pass
def doCleanups(self, doc, output):
pass
FAQ Link to heading
Where to ask for help?
on the pyRevit forum
What is the story behind the preflight checks tool?
David Vadkerti, Ehsan and Jean-Marc converged when Jean-Marc noticed David Vadkerti Model Checker tool, they brought it together with Ehsan to make the core structure of the actual preflight checks tool in Nov 8, 2020