Script to Open PFD Stopped Working - No Error

This script stopped working and I can’t figure out why. Maybe this is an issue outside of pyRevit. Could be something that changed on our server or in bluebeam, I’m not sure.


####################################################################################################
####################################################################################################
# Search and Open Training PDF
####################################################################################################
####################################################################################################
# Imports
# import pyRevit
from pyrevit import DB, revit, script, forms

#import Other
import glob
from pathlib import Path
import subprocess

# ################################################################################
# Debug toggles
globalDebug = False
disabledScript = False

def dprint(*printItems):
    if globalDebug:
        for pI in printItems:
            print(pI)


# ################################################################################
# Generate List
trainingPath = r"L:\Revit\Training"
trainingList = []
trainingDic = {}
trainingSearch = []
for tFile in glob.glob("L:/Revit/Training/*/*.pdf"):
    trainingSearch.append(tFile)
for tFile in glob.glob("L:/Revit/Training/*/*/*.pdf"):
    trainingSearch.append(tFile)
for tFile in trainingSearch:
    trainingList.append(Path(tFile).stem)
    trainingDic[Path(tFile).stem] = tFile

dprint(trainingList)

trainingChoice = forms.SelectFromList.show(trainingList, button_name='Select Topic', multselect=False)
dprint(trainingChoice)

if trainingChoice:
    subprocess.Popen([trainingDic[trainingChoice]], shell=True)

The main question you will have to answer is at what part does the script stop working. Is “trainingList” compiled correctly? Does the form still open? Is the file path still correct for the search? Hope some of that helps.

Sorry, should have posted when I figured it out. The pdf open was being blocked by Threatlocker…

2 Likes