Importing 3D CAD (.DWG) Files into Scenes

Hi all,
I’m exploring the most effective methods for importing 3D CAD (.DWG) files into BabylonJS.

While aware that direct support for .DWG files in BabylonJS is unavailable, I’m interested in the recommended third-party libraries or tools currently used to facilitate this process.

Any insights or guidance on this would be greatly appreciated.


Hi @ertugrulcetin ,

If you find a GLB exporter plugin in your 3D CAD tool, i mean it will be THE solution to convert any of your 3D file formats.

1 Like

Unfortunately, I don’t use any CAD tools, I wanted to know if there are any well-known tools for converting CAD files to glb/gltf/obj formats. I’d like to allow users to import their CAD files and then view them in my BabylonJS viewer.

May be you could try Blender (free) or Sketchup (free before 2018, you can find old versions on the web) only to import your DWG and export it to GLB.

I’ve been using Sketchup for almost 10 years and it is quite easy (much easier than Blender).

1 Like

It is known that there are no such tools for javascript. One needs to convert CAD files to appropriate format.

1 Like

AFAIK, dwg is a closed binary format. You may find open source software that can open it but there is no guarantee it works. I would look for export options from the authoring tool (gltf, obj,…) and see if something is missing in the export.
Another option might be to write a script that exports what you need and do the import inside Babylon.js


DWG is not an open format however DXF is. AutoCAD and most other CAD software can export to DXF so it’s safe to say general 2D (and some 3D) workflows may work for interoperability. I wrote my own DXF writer specifically for my Babylonjs project.

It’s more difficult to parse DXF than to write. There are some DXF JS readers/writers but you will probably have to modify an implementation to your specific needs.

DWG files have primitive and extended object types. There are also other object types that do not easily convert to DXF and would require further workflows to make the geometry primitive. Such as Civil 3D, drainage, swept path etc. It’s not to say you require every object conversion but just be aware DWG can be a minefield. Also, DXF 3D objects such as 3DSOLID types are very difficult to write and parse.

You can look at a server-based solution for converting files, such as assimp.

Another challenge you will get from CAD files is that they support high precision numbers. So geometry may be drawn miles away from origin which is problematic for engines like this.

If the feature you’re building is for general users with basic technical knowledge then I cannot see an import tool working very well. There are a bunch of other challenges in CAD files I could list…


For assimp, there is a port based on emscripten