Skip to content

Instantly share code, notes, and snippets.

@ricaun
Last active January 19, 2025 16:09
Show Gist options
  • Save ricaun/f79a086a0390fa1df2feb182c563bf6d to your computer and use it in GitHub Desktop.
Save ricaun/f79a086a0390fa1df2feb182c563bf6d to your computer and use it in GitHub Desktop.
Revit API in context implementation.
bool InContext(UIApplication application)
{
try
{
void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e) { }
application.Idling += Application_Idling;
application.Idling -= Application_Idling;
return true;
}
catch { } // Invalid call to Revit API! Revit is currently not within an API context.
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment