BIM World
A Professional BIM Learning Platform


Revit Secondary Development: Testing Model Lightweight Conversion from RVT to JSON

Recently, the author has been exploring methods to display lightweight Revit models on web pages. After extensive research, a feasible approach has been identified for sharing these models.

Before diving into the article, it is important to clarify that the conversion of RVT files to JSON format and their subsequent rendering using Three.js on web pages is either not fully implemented or only partially achieved. This results in incomplete data representation. Testing has revealed that the surface data extracted from the model is insufficient, and it remains uncertain whether the basic data interface provided by the Revit API is entirely reliable.

With that said, let’s proceed to the main content.

To convert a Revit model into a JSON file, the Revit API offers an interface called IExportContext. This is a custom export interface provided to users, allowing them to export desired data by implementing its methods. The approach is outlined as follows:

Revit secondary development | Model lightweighting Testing of RVT to JSON Implementation

Based on the author’s research and related materials, this interface is used to facilitate data export. Below are some source code examples and JSON files utilized by the author, available for download for those interested.

Readers can also download these resources directly from the following link:

If you are able to quickly understand the linked code and encounter no issues during testing, you may skip the remaining content.

However, the author frequently encountered the following issue when testing code obtained online:

The given value is not a valid index of a normal of the polymesh. A valid value must be non-negative and less than the total number of normals in the polymesh.

In other words, the provided value is invalid for indexing the polymesh’s normal vector. Valid indices must be within bounds and cannot be negative.

After troubleshooting, the author identified that this exception originates from the PolymeshTopology.GetNormal(idx) method, particularly under certain conditions with PolymeshTopology.

Special thanks to the original author who raised concerns about potential flaws in the Revit API. The exact statement is shown below:

Revit secondary development | Model lightweighting Testing of RVT to JSON Implementation

At present, exporting Revit models to JSON data is only achievable up to this stage. Readers with better solutions or questions are encouraged to leave comments and engage in discussion.

The author commits to sharing any future advancements promptly to benefit the community.

xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Revit Secondary Development: Testing Model Lightweight Conversion from RVT to JSON

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up