kerv
kerv

Reputation: 91

Autodesk Forge - custom viewer

We have an existing three.js application and are experimenting with adding support for cad designs. Previously we managed these with some custom rendering of geojson data that we created from DXF files, but now we're looking to use Autodesk Forge to allow support for more data types and pre-process the data before rendering.

As a preface, we cannot simply just use the Forge viewer threejs version as this would involve us rewriting our entire application to be built as extensions on top of the Forge viewer.

So the plan is, for 3D files, I'm looking at downloading the obj/mtl files from the Forge api and loading those directly in vanilla three.js using their OBJLoader2 example. Based off my initial testing, this appears to work and renders to my liking. I can control how the meshes are created and ensure it is optimized to work within my application.

The problem comes when I'm trying to load 2D files as the forge api only lets me download f2d files which as far as I know, I have no way of loading these using vanilla three.js. Any ideas? Is there another format 2D designs will export as that I might be able to load independently?

Upvotes: 1

Views: 897

Answers (1)

Felipe
Felipe

Reputation: 4375

At the moment I don't know of a simple pipeline to load 2D in plain Three.js. By 2d I am guessing that you mean dwg/dxf, if not the case be more explicit... Forge Model Derivatives REST API doesn't provide another export format from dwg than svf (f2d).

You could convert a 2d dwg into a 3d one by adding a 3d solid to it for example, but then I don't know what the obj export would be, probably not really interesting but you may want to give it a try.

Another option would be to use the Design Automation API with AutoCAD, you could upload a dwg and run some custom dll that would convert the drawing into your custom format that you can then load in your viewer, this will require AutoCAD ObjectARX or .Net API expertise and depending on the complexity of the drawings you plan to handle, may be a fair piece of work.

Finally you may want to consider using the Forge Viewer, even if that means rewriting parts of your app, the viewer is based on Three.js so you may be able to migrate some of your features rather easily, all the UI is just html/css and you can integrate any UI JavaScript framework on top of it. This may end up being a more powerful and flexible solution in the long term than a convoluted pipeline of translations between formats... By exporting 3d to obj you are also loosing all metadata embedded in a CAD file, this may or may not be an issue to you.

I hope that helps

Upvotes: 2

Related Questions