ASP.NET 2.0 Resources

Powered by Blogger

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.
Many Autodesk products support saving to DWF format: AutoCAD® 2006, Autodesk® Architectural Desktop 2006, Autodesk® Building Systems 2006, Autodesk® Civil 3D® 2006, Autodesk Inventor® 9 and 10, Autodesk® Land Desktop 2006, Autodesk® Mechanical Desktop® 2006, Autodesk® Revit® Building 8, Autodesk® Revit® Structure, Autodesk® VIZ 2006, Autodesk® 3ds Max® 8.

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
So what those parameters mean. ToolbarVisible set to False hides user toolbar (on top of viewer), UserInterfaceEnabled parameter controls right mouse click context menu and src attribute points out to DWF file being visualized.

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.

4 Comments:

  • Did u get the solution?
    Im also need the same.

    Can u assist me?

    Thanks in adv.

    Prian

    By Blogger Prian, at 11:21 AM  

  • Hi,
    Awsome blog.

    We are stuck with a similar issue. We need to open a dwf file in asp.net from an original dwg file which is on the server. Then put some markups to the same.
    We then need to save the dwf file back to the server as dwg file.
    Now some one else should also be able to open this dwf in asp.ent page review the markups, edit/delete the markups and save the dwf whic should inturn save the original dwg on the server.

    Is this possible if yes then how can we achieve this.

    By Blogger Rajesh Excelencia, at 7:18 AM  

  • what is tme mime type for .dwg in iis6. i used the same code i get 404 file not found error

    By Blogger prabahar, at 5:11 AM  

  • Hi,

    I am stuck at this point

    'object id="ADViewer" classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF" border="1" width="100%" height="100%" VIEWASTEXT
    param name="ToolbarVisible" value="True"
    /object

    using the above, i can view the dwf file first time with toolbars(Home,MarkUp, Resoureces). But when i open it again that toolbar option is no more, i couldn't see that. I need to fix it,because without that couln't do any editing on dwf file. Please Help me out.

    Tnx

    By Blogger nobody, at 11:10 AM  

Post a Comment

<< Home

Created dolly