Troubles using Autodesk DFW viewer ActiveX 3D API
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:
- Hide all user control interfaces (the viewer will be controled from outside using javascript)
- Establish two way communication channel between viewer and web application
Autodesk DWF Viewer 6.5 contains new feature bottom navigation bar. This bar visibility cannot be controlled with object tag parameter, but luckily there is other way. This navbar can be disabled just after DWF document is loaded in viewer with following javascript code.
<script type="text/javascript" for="ADViewer" event="OnEndLoadItem(bstrItemName,vData,vResult)"> if (bstrItemName == "DOCUMENT") { ADViewer.ExecuteCommandEx("NAVBAR", false); } </script>
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.
<script type="text/javascript"> function fitToWindow() { ADViewer.ExecuteCommand("FITTOWINDOW"); } function setView() { ADViewer.ExecuteCommand("STANDARD_VIEW_FRONTTOPLEFT"); } function selectPart() { ADViewer.ExecuteCommandEx("INVERTSELECTION", 0); ADViewer.ExecuteCommandEx("HIDE", 0); fitToWindow(); } function showAll() { ADViewer.ExecuteCommandEx("SHOWALL", 0); setView(); fitToWindow(); } </script>
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.
The last function selectPart is where i failed to find a solution. This function should select object by it's id or anything, hide all other objects and fit the selected object to whole window. I was able to programmatically hide other object when the object was already selected with mouse, I was able to fit the selected part to whole window. But there is no way to select single object (part) from javascript. There was rudimentary 3D API support in older Autodesk DWF viewer 6.0, but it has changed and I didn't find any usable API function in viewer 6.5.
I have spent almost all day diging into all ActiveX interfaces, searching over the internet with no luck. I didn't find solution for such simple task as selecting part from my javascript code (neither in official API /which does not exist for 3D files/ nor on the internet). There is a lot of discussin about lacking 3D support on Autodesk support forums, but without solutions. They always suggest to wait for feature version that might have 3D API support, but those discussions are dated from the year of 2003.
Did u get the solution?
Im also need the same.
Can u assist me?
Thanks in adv.
Prian