In past few days I was looking for a solution how to display and control 3D DWF files using Autodesk DWF viewer 6.5. I have faced so many problems and also found some solutins that I've decided to share with You. But first some background about DWF viewer for those who haven't seen it before.
Autodesk® DWF™ Viewer allows you to easily view and print 2D and 3D designs in the DWF format, the ideal way to accurately share design information with team members. DWF viewer is available for free download from Autodesk website. It allows you to...
- Access data integral to engineering and architectural design review including drawing scale, precise design coordinates, sheet set details, and object and markup properties.
- Easily view and navigate drawings, maps, and 3D models without the software that created them.
- View and print engineering and architectural files accurately with the same rendering engine as AutoCAD® software.
DWF viewer is also available as ActiveX plugin for Microsoft Internet Explorer. The plugin supports API interface, so you can control opened DWF file programmatically. This API documentation is far from complete, but lets start from the beginning. Integrating DWF viewer with your website is quite easy...
<object id="ADViewer" classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF" codebase="http://www.autodesk.com/global/dwfviewer/installer/DwfViewerSetup.cab" border="1" width="640" height="480"> <param name="src" value="Engine.dwf"> <param name="ToolbarVisible" value="False"> <param name="UserInterfaceEnabled" value="False"> </object>
There are a few parameters that are worth mentioning. I was integrating DWF viewer with the following assumptions:
- Establish two way communication channel between viewer and web application
The code listens for DOCUMENT OnLoad event for ADViewer object and sends NAVBAR disable command to it. This is not documented in official API and may change in feature releases of Autodesk DWF viewer. So are the following commands that we will use. The whole 3D API is not yet officially supported.
fitToWindow function is quite easy, it fits current object to occupate whole window. The setView functions sets standard camera view (Front Top Left) and showAll function shows all objects.