Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

How to Use Global Variables in C# with Revit

1.3K views
•
April 13, 2025
by
Aussie BIM Guru
YouTube video player
How to Use Global Variables in C# with Revit

TL;DR

Global variables in C# can be implemented by creating a static class to store commonly needed objects, allowing access throughout a Revit session. This technique involves subscribing to the idling event to register necessary objects when they become available. The approach provides a workaround for the lack of native global variable support in C#.

Transcript

[Laughter] youo there you're watching the oim guru and today we're going to cover a topic that I actually forgot we need before we look at tool tips and icons so sorry if you're looking forward to that lesson we're going to do that next but today we're looking at Global variables so we're going to look at setting up a Global's class which will give... Read More

Key Insights

  • Global variables are implemented in C# by creating a static class to store objects.
  • The idling event in Revit is used to register UI applications when available.
  • C# does not natively support global variables, requiring workarounds.
  • Delegation in C# attaches methods to events, allowing them to run together.
  • Global variables provide access to commonly needed objects across a project.
  • Using regions in code helps organize and collapse sections for clarity.
  • Global variables are set up using a method to register properties at startup.
  • The idling event is subscribed to once and unsubscribed immediately after use.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How to implement global variables in C# for Revit?

Global variables in C# for Revit are implemented by creating a static class, such as a Global's class, to store objects and properties needed throughout the session. This involves setting up properties within the class and using methods to register these properties at the program's startup, ensuring they are accessible globally.

Q: What is the role of the idling event in Revit?

The idling event in Revit is used to register UI applications and other necessary objects when they become available. By subscribing to this event, developers can execute code once the application is in an idling state, ensuring that essential objects are registered and ready for use across the project.

Q: Why are global variables important in programming?

Global variables are important because they provide a way to store and access commonly needed objects and properties across different parts of a program. This reduces redundancy, enhances efficiency, and simplifies code maintenance by allowing multiple components to share data without passing parameters repeatedly.

Q: How does delegation work in C#?

Delegation in C# involves attaching methods to events, allowing them to run together when the event is triggered. This technique enables one method to delegate tasks to another, facilitating event-driven programming by executing additional code when specific events occur, such as the idling event in Revit.

Q: What are the benefits of using regions in code?

Using regions in code allows developers to organize and manage code sections by collapsing and expanding them. This improves readability, makes the codebase cleaner, and helps developers focus on specific parts of the code without distraction, enhancing overall code maintenance and collaboration.

Q: How are global variables registered at startup?

Global variables are registered at startup by calling a method within the static class designed to set up properties. This method initializes the necessary objects and properties, ensuring they are available for use throughout the program. The registration typically occurs in the program's startup sequence.

Q: What is the workaround for C#'s lack of native global variable support?

The workaround for C#'s lack of native global variable support involves creating a static class to store global variables and using methods to register and access these variables. This approach simulates global variable behavior by making objects and properties accessible across the entire project scope.

Q: When should the idling event be unsubscribed?

The idling event should be unsubscribed immediately after the necessary code has been executed to prevent it from running repeatedly. This ensures that the event only triggers the desired actions once, maintaining program efficiency and avoiding unnecessary processing during the application's idle state.

Summary & Key Takeaways

  • Global variables in C# are implemented using a static class to store and access commonly needed objects throughout a Revit session. This method involves subscribing to the idling event to register necessary objects when available, providing a workaround for C#'s lack of native global variable support.

  • The tutorial demonstrates creating a Global's class, setting up properties, and using the idling event to register UI applications and usernames. This approach ensures that essential objects are accessible globally within the project, enhancing efficiency and code organization.

  • Code organization is improved by using regions to collapse and expand sections, making the codebase cleaner and more manageable. The tutorial emphasizes the importance of setting up global variables early in the project to facilitate access across different parts of the code.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from Aussie BIM Guru 📚

C# + Revit: Lesson 6 - Create a PushButton! thumbnail
C# + Revit: Lesson 6 - Create a PushButton!
Aussie BIM Guru
C# + Revit: Lesson 4 - Introduction to Classes! thumbnail
C# + Revit: Lesson 4 - Introduction to Classes!
Aussie BIM Guru
C# + Revit: Lesson 5 - Introduction to Interfaces! thumbnail
C# + Revit: Lesson 5 - Introduction to Interfaces!
Aussie BIM Guru

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.