/gingerbread

A lightweight gbXML export module for Revit. WIP

Primary LanguageC#BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

gingerbread 🍘

.NET wakatime

A lightweight gbXML export module for Revit, WIP. Sometimes we find the Revit model much too complex for an accurate and lightweight gbXML export. There may be broken space boundaries, shattered surfaces, or tiny twisted patches, thus leading to failures in the building energy simulation. In this toy project we provide a simple BREP-like space crafting plugin with fuzzy space detection and simplification, aside from the native gbXML export module either based on room/space definition or energy analysis model.

gingerbread
├ /docs
└ /Gingerbread
  ├ /Properties   - Assembly info
  ├ /Resources
  │ ├ /ico        - Icons
  │ ├ /lib        - Clipper.cs
  │ └ /spider     - Spider gbXML viewer
  ├ /Views        - WPF functions
  ├ /Core         - Basic Algorithms
  ├ App.cs        - App entry
  ├ Cmd*.cs       - Button entry
  ├ Ext*.cs       - External event
  ├ Util*.cs      - Utility functions
  └ Gingerbread.addin  - App manifest

Dependency

Compile

  • Revit 2023 - CefSharp 65.0.1 - Visual Studio 2022
  • Make sure the Build/Debug platform is switched to x64
  • Post-build event settings:
if exist "$(AppData)\Autodesk\REVIT\Addins\2023" copy "$(ProjectDir)*.addin" "$(AppData)\Autodesk\REVIT\Addins\2022"
if exist "$(AppData)\Autodesk\REVIT\Addins\2023" mkdir "$(AppData)\Autodesk\REVIT\Addins\2022\Gingerbread" mkdir "$(AppData)\Autodesk\REVIT\Addins\2022\Gingerbread\Spider"
copy "$(ProjectDir)$(OutputPath)*.dll" "$(AppData)\Autodesk\REVIT\Addins\2023\Gingerbread"
copy "$(ProjectDir)$(OutputPath)\Resources\spider\*.*" "$(AppData)\Autodesk\REVIT\Addins\2023\Gingerbread\Spider"

Demo
Snapshot
Project is under development, with Document / Log updated once in a while.

Test it with Technical_school-current_m.rvt shipped with Revit.

Note
Some notes about the WPF and CefSharp

  • All WPF windows inherit from one base window class where the border and title bar are customized. You may refer to BaseWindow.cs and BaseWindowStyle.xaml and see how that works.
  • I use Properties.Settings.Default to cache some user settings and bind them in XAML textbox.
  • External events are called by clicking the button of WPF window. Likely, with Delegate and Dispatcher, a progressbar is added to the main window monitoring the processing of an external event. DoEvent is not optimal. Here's a great sample of this kind of progressbar: engthiago/WPFMonitorRevitAPI
  • Several ways to embed the Web browser. 1. Using CefSharp in line with Revit and call local website dynamically (in .cs), but I don't know how to pass variable to JavaScript because there seems a conflict between plugin and Revit when initializing a browser. 2. Still with CefSharp but initializing local website within XAML. This is the current solution. Without the data communication users have to load XML manually which is dumb. 3. Try other C# dependencies like DotNetBrowser that has no conflicts with Revit (Not free). 4. Open up another process for CefSharp, parallel to Gingerbread. Refer to Kim Sivonen

If you got better solution please let me know. Many thanks.