Skip to content

dolanklock/revit-rooms-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Export Revit Room Boundaries to Json and GeoJson


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

A pyRevit add-in that exports room boundaries as well as specified room properties into .json (topojson) or .geojson files. The exported room information contains the "Number" and "Level" properties as default. This add-in allows users to use the exported Revit room plans to create data visualizations (such as for a Power BI report or a React app). For further information on the uses, visit the Usage section.

(back to top)

Built With

  • Python (version 3.8)
  • Revit (Revit 2022+)

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Install the required programs and software below

  • pyRevit

    https://pyrevitlabs.notion.site/Install-pyRevit-98ca4359920a42c3af5c12a7c99a196d
  • Python 3.8

    https://www.python.org/downloads/release/python-380/

    Go down to the "Files" section on the page and select / download the correct installer based on your operating system. For example, if you are on windows machine then you would select this installer - "Windows x86 executable installer" (see image below)

Installation

  1. Clone the repo. You need to clone the repository in order to get the a local copy of the repo on to your computer. Then you can load this add-in in to Revit through pyRevit (see step 2)

  2. How to clone a repository

    https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository

    After you clone the repository, go to pyRevit tab in Revit and select the pyRevit down arrow

    Select settings

    Select "Add Folder" and navigate to where you saved the cloned repository. You should navigate to the directory just before the .extensions folder and select ok. You should see a folder path something like this *Make sure the path is to the directory just before the .extensions directory. Select "Save Settings and Reload"

    You should now see the toolbar loaded!

  3. Install packages #TODO: add instructions for virtual environment setup then install requirements packages there?

    pip install requirements.txt

    #TODO: add instructions for pip installing requirements file

  4. Update environment variables #TODO: add steps for adding "PYTHONPATH" to environemnt variables. If create virtual environment will that affect where this is pathed to?? should path to venv?

    
    
    

(back to top)

Usage

This add-on was originaly designed to use Revit room geometries in Power BI reports, but can be applied to any program or script using geojson (.geojson) or topojson (.json) files. Currently the add-on does not support ellipse shaped Revit room geometries.

Select rooms, export file type, and data exported (defaults to room Number and room Level):
NOTE: "Ignore inner boundaries" is the option of simplifying the shape by ignoring inner boundaries

1. Power BI

  • Use the add-on to export topojson files.
  • STEP 1: To import data from revit rooms into Power BI:
    • Go to "Get data from another source" option, choose JSON, navigate to your topojson file and "Open". This should open the Power Query Editor window.
    • You will see an imported table, and some automatic steps created under "Applied Steps" on the right. Ignore this and go to Advanced Editor at the top Home ribbon.
      --> replace the contents with the code below.
      --> at the first row under "let" replace: PATH TO TOPOJSON and TOPOSON FILE NAME
      --> at the last row under "let" replace at both instances: {"Number","Level"} by all Revit properties to be linked to the room plan.
let
    Source = Json.Document(File.Contents("PATH TO TOPOJSON\TOPOJSON FILE NAME.json")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Removed Columns" = Table.RemoveColumns(#"Converted to Table",{"bbox", "arcs", "type"}),
    #"Expanded objects" = Table.ExpandRecordColumn(#"Removed Columns", "objects", {"object_name"}, {"object_name"}),
    #"Expanded object_name" = Table.ExpandRecordColumn(#"Expanded objects", "object_name", {"geometries"}, {"geometries"}),
    #"Expanded geometries" = Table.ExpandListColumn(#"Expanded object_name", "geometries"),
    #"Expanded geometries1" = Table.ExpandRecordColumn(#"Expanded geometries", "geometries", {"properties"}, {"properties"}),
    #"Expanded properties" = Table.ExpandRecordColumn(#"Expanded geometries1", "properties", {"Number", "Level"}, {"Number", "Level"})
in
    #"Expanded properties"
  • STEP 2: To link room geometries with data:

    • Place a Shape map visual on the report. NOTE: At the time of this writing, Shape map visual is a beta feature, it must be enabled by checking its checkbox by going to File > Options and settings > Options > Preview features > Shape map visual (https://learn.microsoft.com/en-us/power-bi/visuals/desktop-shape-map)
    • In Build visual, the "Number" field should be dragged under "Location". Any distinct field can be used, as long as it can act as keys between the data and the room geometries.
    • In Format your visual go to Map settings > Map type > Custom map. Under Add a map type browse for your topojson file.
    • Go back to Build visual to link additional data to the floor plan. For example, drag the "Area" field under "Color saturation".

    NOTE: Data coming from any external source can be linked to the floor plan (i.e imported data from an excel), as long as there is a column field in that external data that will act as the linking key with the field specified under "Location" under Build visual.
    For example, an external source containing a Number column that correlates with the topjson Number field dragged under "Location"


EXAMPLE
Fields exported from Revit include Number, Level, and Area. Area was converted to a decimal number type of data in the Table view and used in the slicer visual. The slicer is adujsted to highlight rooms matching the specified area range.
For more information regarding the Shape map visual go to

https://learn.microsoft.com/en-us/power-bi/visuals/desktop-shape-map


2. React JS

  • Use the add-on to export topojson files.
  • Import geojson files to react applications using react leaflet

https://react-leaflet.js.org/ https://stackoverflow.com/questions/60470752/importing-geojson-file-to-react-leaflet

(back to top)

Contributing

Currently the add-on does not support ellipse shaped Revit room geometries.

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Anna Milczarek go to github - email: anna_milczarek@hotmail.com
Dolan Klock go to github - email:

Project Link: https://github.com/dolanklock/revit-rooms-to-json

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages