Script Sharing Forum?

Hey there! I have a few scripts I would like to share and/or get some input on. Is there anywhere that has a repository of user created scripts that I can upload to or download from to get some input or new ideas? Thanks!

Most commonly you create your own repo on GitHub and add the files as an extension format. If it setup correctly and of high quality it can be shared in the extension manager by the pyRevit team.

Some more detailed advice (by ChatGPT):

To create a pyRevit extension and share it on GitHub for community feedback, follow these steps:


1. Structure Your pyRevit Extension

A pyRevit extension is a collection of scripts organized in a specific folder structure.

Basic Structure

MyPyRevitExtension/
│── MyPyRevitExtension.extension/
β”‚   │── bundle.yaml
β”‚   │── MyTab/
β”‚   β”‚   │── MyPanel/
β”‚   β”‚   β”‚   │── MyButton.pushbutton/
β”‚   β”‚   β”‚   β”‚   │── script.py
β”‚   β”‚   β”‚   β”‚   │── icon.png
β”‚   β”‚   β”‚   β”‚   │── bundle.yaml
  • MyPyRevitExtension.extension/ β†’ Main extension folder
  • bundle.yaml β†’ Metadata file defining the extension
  • MyTab/ β†’ Custom tab in the Revit UI
  • MyPanel/ β†’ A panel inside the tab
  • MyButton.pushbutton/ β†’ A push button that runs a script
    • script.py β†’ The main Python script
    • icon.png β†’ Button icon (optional)
    • bundle.yaml β†’ Button settings (e.g., tooltip, script path)

2. Write Your Scripts

Your script.py should be compatible with Revit’s API. Example:

# script.py
from pyrevit import forms
from Autodesk.Revit.DB import *

doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

# Select elements
selection = uidoc.Selection.GetElementIds()

if selection:
    elems = [doc.GetElement(id) for id in selection]
    elem_names = [elem.Name for elem in elems if hasattr(elem, "Name")]
    forms.alert(f"Selected elements: {', '.join(elem_names)}")
else:
    forms.alert("No elements selected.")

3. Define Metadata (bundle.yaml)

Each extension and button has a bundle.yaml file.

For the Extension

Create MyPyRevitExtension.extension/bundle.yaml:

name: MyPyRevitExtension
author: YourName
type: extension
description: "A set of tools for Revit users."

For the Button

Create MyButton.pushbutton/bundle.yaml:

tooltip: "Select elements in the model"
author: YourName
context: "zero-doc"
icon: icon.png
script: script.py

4. Test Your Extension in pyRevit

  1. Load the extension into pyRevit

    • Move your extension folder (MyPyRevitExtension.extension) into:
      • %AppData%\pyRevit\Extensions\ (Windows)
      • OR set a custom extension directory in pyRevit CLI.
  2. Reload pyRevit:

    • Open Revit, go to pyRevit tab, and click Reload pyRevit.
    • Your new tab and button should appear.

5. Publish to GitHub

Initialize Git & Push to GitHub

  1. Open a terminal inside MyPyRevitExtension/ and run:

    git init
    git add .
    git commit -m "Initial commit"
    git branch -M main
    git remote add origin https://github.com/yourusername/MyPyRevitExtension.git
    git push -u origin main
    
  2. Add a README.md

    • Explain how to install and use your extension.

6. Share with the Community

Install from GitHub

Users can install your extension directly using pyRevit CLI:

pyrevit extend user extensions add MyPyRevitExtension https://github.com/yourusername/MyPyRevitExtension.git
pyrevit reload

Ask for Feedback


Bonus: Automate Installation (Optional)

Create a install.py script to clone the repo and install:

import os
import subprocess

repo_url = "https://github.com/yourusername/MyPyRevitExtension.git"
install_dir = os.path.expanduser("~/AppData/Roaming/pyRevit/Extensions/")

if not os.path.exists(install_dir):
    os.makedirs(install_dir)

subprocess.run(["git", "clone", repo_url, os.path.join(install_dir, "MyPyRevitExtension.extension")])
print("Installation complete. Restart Revit and reload pyRevit.")

Users can run this script to install your extension.


Next Steps

  • Improve UI: Add icons, better UI controls (e.g., WPF, WinForms).
  • Get Issues & Contributions: Encourage users to submit GitHub issues and pull requests.
  • Package with pyRevit CLI: Create .extension.zip for easy distribution.
1 Like