Embedding links in Output Window?

First post! I have to say, I love this software! I’ve already started developing tools to simplify workflows at my company, and it’s so much faster than the last thing I used (AutoLisp, ugh gross).

I was reading on the developer docs page about Effective Output, and I love the idea of clickable element links. Is there a way I can accomplish something similar to link to network folders, or even websites? I tried using the following code, but it didn’t really work like I expected:

from pyrevit import script
output = script.get_output()
output.print_html(‘Link 1’)
output.print_html(‘Link 2’)

The first link successfully takes me to google in my default web browser, so that’s a win. The second link opens the PDF inside the Output Window. Repeating Link 2 with just the folder path does not open. It’s possible I just don’t know enough html, but I figured I would just ask for suggestions.

Ok so the script is getting parsed incorrectly by the website. Here’s my code:

Screenshot 2021-07-22 180642

Hi,
I hope I will ge the answer you need:

first guess:
with the correct syntax

output.print_html('<a href="file:///C:/Users/rpl/Downloads\clx.pdf">sample text</a>')

if through a button:

you can create a button of type urlbutton making a folder named: yourFunction.urlbutton
then create a bundle.yaml file containing your url:
hyperlink: "https://www.notion.so/pyRevit-bd907d6292ed4ce997c46e84b6ef67a0"

documentation here: Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.

1 Like

Thank you, I’ll give this a try on Monday! Is there an easy way to make the folder link path a variable? My biggest concern is the syntax of the slash marks since they also function as escape characters.

I tried your solution, but unfortunately it provided the same result as before. The PDF link opens inside the log, and the folder does not open.

if you want to open folder inside the output window you can achieve it this way:

import subprocess
subprocess.Popen(r'explorer /select,"C:\YOUR_FOLDER\doNotErase-pointer"')

You need to point the script to open a specific file in my case “doNotErase-pointer” which can be hidden in OS.

1 Like

I will try that tomorrow. Ideally I’d like to open the folder and the PDF outside of the output window though.

Sorry, actually the script above opens a folder in File Explorer.
If you want to open the folder in the output window this is the way:

from pyrevit import script
output = script.get_output()
output.open_page(YOUR_FOLDER_PATH)
2 Likes

So close! The subprocess.Popen() method will work for my application, but it doesn’t trigger with a link. Ideally the user can choose if they want to open the file or folder by clicking a link, rather than having it open every time.

For the record, here’s the code I used for dynamic paths:

import subprocess
command = r'explorer ' + "\"" + your_path + "\""
subprocess.Popen(command)
1 Like