How to adapt the Preflight Checks

Hello!
I was wondering if you could help me find more information about how to change and adapt the Preflight checks or even make my own. I have tried searching here and in the Notion page but nothing clear appears.
Thank you for your time,
Bittor

Hi and welcome on the forum.

  • The ‘checks’ are all located in a ‘checks’ folder at the root of any extension folder (meaning even in your custom extension folder). The basic ones that comes with pyrevit as well:
  • From there, you can start by duplicating any of the suffixed *_check.py files, the extension of the filename being the important part

  • In the file itself, the important parts are:


from pyrevit.preflight import PreflightTestCase

def checkModel(doc, output):

    # your tests and its outputs with a very basic thing as an example

    title = doc.Title

    output.print_md('# data I want to display to the end user')
    output.print_md('Title of the document opened is **{}**'.format(title))
    

class ModelChecker(PreflightTestCase):
    """
    Description of what it does

    """

    name = "title listed in the preflight checks ui"
    author = "your name"

    def setUp(self, doc, output):
        pass

    def startTest(self, doc, output):
        timer = coreutils.Timer()
        checkModel(doc, output)
        endtime = timer.get_time()
        endtime_hms = str(datetime.timedelta(seconds=endtime))
        endtime_hms_claim = "Transaction took " + endtime_hms
        print(endtime_hms_claim)

    def tearDown(self, doc, output):
        pass

    def doCleanups(self, doc, output):
        pass

Note: I typed it from my phone, there might be typos.

If you want to improve the model checker check itself, please, do not hesitate to make a PR against the develop branch and I will review and merge.

1 Like

I see, thank you very much Jean-Marc