DevCamps 2008 - Customization and Application Development Conferences

Last year we held our first DevCamps for AEC and Manufacturing customers & partners. Following on from their success, this year's events are fast approaching: this year we've added Geospatial into the mix, and are holding DevCamps through the month of June.

Manufacturing DevCamp
June 11-13, 2008
Portland, Oregon

Architecture, Engineering & Construction DevCamp
June 16-18, 2008
Wakefield, Massachusetts (near Boston)

Geospatial DevCamp
June 25-27, 2008
San Rafael, California (near San Francisco)

This is really a good opportunity to meet and get to know members of my team (DevTech) and Autodesk's engineering teams, as well as getting first-rate information on how to develop with Autodesk APIs.

For more information and links to the respective registration pages, go to http://www.autodesk.com/devcamp2008.

May 14, 2008 in Training | Permalink | Comments (1) | TrackBack

Autodesk University 2008: putting it to a vote

The organizers of AU are asking people to vote on the sessions they'd most like to attend at this year's conference.

The sessions being presented by my team are not part of that list, so here they are, in case any of you completing the survey were wondering about them. I should mention that at this stage the below sessions are still subject to change.

Platforms (AutoCAD, RealDWG, AutoCAD OEM, DWF)
Product API Title
AutoCAD All AutoCAD APIs: The Right Tool for the Job
AutoCAD .NET AutoCAD .NET Basics
AutoCAD .NET AutoCAD .NET: A Tour
AutoCAD .NET AutoCAD .NET: Developing a User Interface
AutoCAD .NET AutoCAD .NET: Using .NET with your LISP applications
AutoCAD ObjectARX,
.NET
AutoCAD APIs: Meet the Experts
AutoCAD ObjectARX,
.NET
ObjectARX: Improving Application Performance and Handling Large Data Sets
AutoCAD ObjectARX ObjectARX: Easy ways to crash your AutoCAD Addin (and how to avoid them)
RealDWG,
AutoCAD OEM,
DWG TrueView
ObjectARX,
.NET, COM
There's more to DWG than AutoCAD
DWF Toolkit,
Design Review
C++, COM Enrich Your DWF
AutoCAD .NET AutoCAD .NET: Developing for AutoCAD using F#
AutoCAD .NET AutoCAD .NET: Advanced UI Design using WPF
AutoCAD .NET AutoCAD .NET: BRep Basics
 
AEC (Architecture, Engineering & Construction)
 
Product API Title
Revit Architecture/
Structure/MEP
.NET The ABCs of Programming Revit
Revit Architecture/
Structure/MEP
.NET The Revit SDK Sample Smörgåsbord
Revit Architecture/
Structure/MEP
.NET Enhancing Your Revit Add-In
Revit MEP .NET The Ins and Outs of Revit MEP Programming
AutoCAD Architecture .NET AutoCAD Architecture - Introduction to the .NET API
AutoCAD Architecture .NET AutoCAD Architecture - .NET API advanced topics
Revit Structure .NET Revit Structure API – from bidirectional link to rebar detailing
Revit Architecture/
Structure/MEP
.NET A Closer Look at the Revit® Database with the Revit API
AutoCAD Architecture .NET AutoCAD® Architecture .NET API - Customizing with the AEC Detail Framework
AEC products All AEC API Talk
AutoCAD MEP .NET AutoCAD MEP .NET Programming: In-Depth
 
Manufacturing
 
Product API Title
Inventor COM Inventor API: Introduction to Inventor Parts
Inventor COM Inventor API: Introduction to Inventor Assemblies
Inventor COM Inventor API: Introduction to Inventor Drawings (idw)
Inventor COM Inventor API: Exploring iProperties and Parameters
Inventor COM Inventor API: Taking the Step from VBA Macros to Add-Ins
Inventor COM How Deep is the Rabbit Hole? Examining the Matrix and other Inventor Math and Geometry Objects
Inventor COM Inventor API: New Features in Inventor 2009
Vault Web services Introduction to the Autodesk Vault API
Productstream Web services Introduction to the Autodesk Productstream API
Productstream Pro .NET Introduction to Autodesk Productstream Professional
AutoCAD Electrical LISP Introduction to the AutoCAD Electrical API
Inventor COM Inventor API: Using Inventor’s Graphics API
 
Geospatial
 
Product API Title
AutoCAD Civil 3D COM Getting Started with Civil 3D Application Programming using VBA
AutoCAD Civil 3D COM Civil 3D API: Working with Alignments and Profiles
AutoCAD Map 3D .NET Introduction to the Map 3D Platform API
AutoCAD Map 3D .NET Access, Query and Analyse Spatial Data using the Map 3D Platform API
Feature Data Objects .NET Introduction to FDO Programming
Topobase .NET Managing City Water Network using Topobase API
MapGuide Enterprise .NET Getting Started with MapGuide Enterprise Programming
MapGuide Enterprise .NET Integrating your MapGuide Enterprise Application with Other Systems

While these sessions are not being put to the vote, feel free to post comments or send me an email on the programming-related sessions you'd most like to see, whether in this list, or not.

May 1, 2008 in Training | Permalink | Comments (0) | TrackBack

Autodesk University 2008: last call for presenters

The ADN team delivered around 50 classes at AU 2007, and we're currently planning on delivering around the same number at AU 2008.

(A quick note on the classes I'll be delivering: I'm planning to deliver a class on programming AutoCAD with F#, as well as delivering the "There's more to DWG than AutoCAD®" and "Enriching your DWF™" classes from last year.)

Joseph Wurcher, manager of AU Program Development and author of BLAUG, asked me to pass on the below "last call for presenters" to this blog's readership.

Two words: submissions deadline. If you’re considering joining our outstanding slate of speakers at Autodesk University 2008, you’ll have to act by April 27, 2008.

Please submit your presentation proposal(s) online, as soon as possible, at the Call for Papers website.

Whenever we stop to analyze why Autodesk University has become so hugely successful, one thing is clear: the excellent presentations from experts  are a big, big factor.

The time for us to assemble the AU 2008 faculty, who are without a doubt the most critical component of the overall AU experience, is nearly over. So if you:

  • Have the communication skills, technical expertise, and relevant experience...
  • Want to share your knowledge of a favorite topic—from tips and tricks and sales techniques to new business opportunities such as sustainable design...
  • Are motivated to bring success to design professionals and their organizations...
  • Want to demonstrate your expertise to several thousand Autodesk customers, partners, and employees, thereby promoting your business success...

... Then we want to hear from you—now!

A speaker honorarium is also provided.

Joseph

It would be great to see more "Customization & Programming" classes from readers of this blog, for instance. See you in Vegas! :-)

April 22, 2008 in Training | Permalink | Comments (0) | TrackBack

A good resource for finding out about the newer features in C#

I've mentioned before how much I appreciate the content on MSDN's Channel 9.

For those of you who are familiar with C# 1.0, but haven't yet taken the time to dive into the language features introduced since then, I strongly recommend the "whirlwind" series posted on Channel 9.

Here's a quick description of what these whirlwinds are all about:

Whirlwinds are bite-sized webcasts, each is shorter than 15 minutes. You can start anywhere in the series to learn about the parts you're most interested in.

Here are links to the individual whirlwinds:

I like the short format and can see it being relevant to individual (or small groups of) API features exposed by our products (a little like mini-DevTV sessions). If any of you have input about the concept, please post a comment or send me an email, ideally letting me know of specific topics in which you'd be interested.

April 14, 2008 in Training, Visual Studio | Permalink | Comments (0) | TrackBack

Leaving Las Vegas

I'm sat here at McCarran airport, tapping in a quick post before flying off to Boston. I didn't get the chance to post on the happenings this week at AU (or about anything much else, for that matter), but many others have, so I expect that's OK.

I have to say I really enjoyed this year’s AU, even if I’m now feeling a little frazzled. It was a real pleasure to put so many faces to names over the course of the week, as well as to catch up with old acquaintances.

I'd also like to say a quick (but big) "thank you" to all the presenters and attendees who made the Developer Track at this year's Autodesk University such a success. Early feedback indicates the sessions were generally very well received, and I know my team certainly enjoyed the opportunity to present and to engage in so many interesting discussions. I fully expect us to run a Developer Track of a similar (or greater) scale at AU 2008, with appropriate tweaks/enhancements based on the feedback we receive.

If any of you have input on what we might improve for next year, please post a comment or send me an email.

Thank you very much (said in my best Elvis voice, of course).

November 30, 2007 in Training | Permalink | Comments (1) | TrackBack

DevTV: Introductory recordings on Autodesk APIs

My team has been working very hard on some recordings of introductory presentations around our APIs. Here is the first batch of recordings we've just posted as part of our DevTV series (the idea being these are recordings that are "produced", while our webcast recordings are somewhat raw):

Introduction to AutoCAD .NET Programming  view  download (148 MB)
Introduction to Inventor Programming  view  download (51.7 MB)
Introduction to Revit Programming  view  download (64.3 MB)
Introduction to Civil 3D Programming  view  download (27.3 MB)
Introduction to MapGuide Enterprise Programming  view  download (37.4 MB)

Enjoy! :-)

November 2, 2007 in Training | Permalink | Comments (32) | TrackBack

AU Handouts: Enriching Your DWF™ - Part 2

[This post continues from part 1 of this series. The source for the below applications is available here: DWF Toolkit application source, Design Review application source & Freewheel application source.]

Mining the data with the DWF Toolkit

Now we’re going to look at using the DWF Toolkit – the freely available, cross platform toolkit for creating and reading DWF files – to extract the “identity” and “material” metadata associated with our geometry.

The DWF Toolkit is a C++ toolkit, so we have two components to our project:

  1. A C++ DLL that uses the DWF Toolkit to read a DWF, storing the data we care about in XML
  2. A VB.NET module that implements a user interface for viewing the XML content.

By its nature, DWF Toolkit client code tends to be somewhat complex, as it closely follows the internal structure of the DWF format, so I’m not going to go into the code. I will just say that you need to be a competent C++ programmer to work with the DWF Toolkit – it is not for the casual developer to dip into. There are clearly cases where using the DWF Toolkit makes a lot of sense – such as using it to modify or post-process DWFs non-graphically - but where possible I would recommend using a “higher level” API such as the API to Design Review or the publishing APIs within AutoCAD (just as we saw earlier).

The full source code for the project is posted to my blog, and here is what the application looks like:

Dwf_toolkit_application Dwf_toolkit_application_2

Figure 12 – a DWF Toolkit application to extract our metadata

Linking 2D with 3D DWF data in an application embedding Design Review

In the next part of our demo, we’re going to make use of the metadata embedded in our DWF file to link the 2D and 3D sheets of our DWF.

Emedded 2D and 3D view onto DWF data actually have quite different API capabilities: 2D views have a set of events that you can respond to, to determine when objects are hovered over or selected (which you cannot receive for objects in 3D views), while 3D views allow you to manipulate object visibility and transparency (something you cannot control for objects in 2D views).

So we’re actually going to play to the strengths of the two API sets: we’re going to respond to an event when objects are hovered over in the 2D view, and during that callback we’re going to manipulate the 3D view to “isolate” the object in that view. And the way we’re going to link the two views is via the metadata that’s attached to our objects.

The HTML code is too long to include in its entirety here, so I’m going to describe the overall functionality and leave it to the reader to work through the code at their own pace. I will post the full source in a blog entry, though (as well as making it available for download there).

One of the key things is that in our “OnOverObject” callback (which we respond to with JavaScript code in our HTML), is that we receive a geometry index (a node ID) for the object that’s being hovered over. This, in itself, isn’t directly useful, so we need to find a way to map it to the objects in question. I managed to do this by hosting the object identity (handle) metadata in a combobox, populated in the same order as the geometry IDs we receive. So it’s very important that we populate the combobox appropriately, even if it’s hidden (which in our case it isn’t – we also make it available for the user to select objects by their handle).

Let’s look at how we embed our two views – both onto the same DWF file. Here’s the object tag for the 3D view:

<object

  id="ObjectView"

  width="100%"

  height="100%"

  classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF"

  codebase= "http://www.autodesk.com/global/dwfviewer/installer/DwfViewerSetup.cab#version=7,0,0,928"

  VIEWASTEXT

>

  <param name="src" value="solids.dwf?section=1">

</object>

We have used the src property to set the appropriate section by using “?section=1” to specify the first one.

With the 2D sheet we’ve taken a slightly different approach:

<object

  id="Canvas"

  width="100%"

  height="100%"

  classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF"

  codebase= "http://www.autodesk.com/global/dwfviewer/installer/DwfViewerSetup.cab#version=7,0,0,928"

  VIEWASTEXT

>

  <param name="src" value="solids.dwf">

</object>

We have not selected the sheet here – to avoid timing issues we’ve done so in the EndLoadItem JavaScript callback of the 2D view’s document:

if (Canvas.SourcePath != "solids.dwf?section=2")

{

  Canvas.SourcePath = "solids.dwf?section=2";

}

Much of the rest of the code is around user interface tweaks, such as forcing the “Orbit” mode by default in the 3D view, and the “Select Object” mode in the 2D view. We also disable the toolbars etc., to reduce dialog clutter.

Design_review_application_2

Figure 13 - embedding and linking multiple Design Review windows in an HTML application

Hosting an embedded Freewheel view in a custom web-page

Freewheel – and its Labs sibling, Project Freewheel – is a zero-client AJAX (Asynchronous JavaScript and XML) technology for working with both 2D & 3D DWF content. The DWF file resides on a server – whether uploaded securely by the user or hosted on a publicly-accessible web-page – and the graphics for the current view on the DWF content are piped down to the HTML client via raster. It’s impressively responsive, even when orbiting in 3D.

We don’t get the same ability to view and work with metadata (at least not right now), but it is still a compelling experience if you want to embed lightweight navigation for DWF without forcing an install of Design Review on the client machine. It’s also getting some very cool collaborative review capabilities, to allow multiple people to mark 2D or 3D designs up in real-time. Very cool stuff, but not today’s subject, I’m afraid.

The first thing is to get our design into Freewheel. One option is to use the “Share Now” utility available from Autodesk Labs, which publishes to DWF and uploads to Freewheel, or we could upload it via the Freewheel user-interface, as we have a DWF file ready-to-go.
In our case, however, I’ve already posted a version of the DWF file to a publicly-accessible internet location, so we’re going to use that:

http://through-the-interface.typepad.com/presentations/DWF/solids.dwf

A quick note on using Autodesk Freewheel vs. Project Freewheel. Autodesk Freewheel (http://freewheel.autodesk.com) is the production environment for Freewheel, and is hosted on a high-availability, load-balanced server farm. Project Freewheel (http://freewheel.labs.autodesk.com) is hosted on a PC under someone’s desk (OK, that’s an exaggeration :-), but contains the latest & greatest functionality. I’ve found that the DWF files I’ve been creating for this demo are best viewed with the Project Freewheel server, so I’m using that, today, but I recommend you first try with the production system when implementing your own Freewheel-powered sites.

The two basic approaches for including a Freewheel view in your website are to link or to embed. Linking is simple: you create a standard HTML link with a URL pointing Freewheel to your DWF file:

<a href="http://freewheel.labs.autodesk.com/dwf.aspx?dwf=http://through-the-interface.typepad.com/presentations/DWF/solids.dwf">My link</a>

This creates a straight link to the Freewheel view. As with any HTML link, you can choose to launch this in a new window using the target property. You might also want to show a different page – you do this using the “sec” argument, which is the page/sheet number starting from 1:

<a href="http://freewheel.labs.autodesk.com/dwf.aspx?sec=2&dwf=http://through-the-interface.typepad.com/presentations/DWF/solids.dwf">My link</a>

Next we’re going to embed a view. We do this using an HTML iframe:

<iframe

  frameborder="0"

  height="300"

  width="400"

  scrolling="no"

  src="http://freewheel.labs.autodesk.com/dwf.aspx?sec=2&dwf=http://through-the-interface.typepad.com/presentations/DWF/solids.dwf">

</iframe>

Once again, you can use the “sec” parameter to select a particular sheet. This creates a navigable view on your DWF file.

Aside from linking or embedding, Freewheel exposes an ever-growing set of web services APIs, to allow you to render a particular view of a DWF to raster or to get information about a DWF, such as the number of pages, etc.

We can use the dwfImage web service to get an image of a DWF to use as a thumbnail:

<img

  frameborder="0"

  height="150"

  width="200"

  scrolling="no"

  src=

"http://freewheel.labs.autodesk.com/dwfImage.aspx?page=1&width=200&height=150&path=http://through-the-interface.typepad.com/presentations/DWF/solids.dwf" /

>

We can throw these together and create a web-page that links from the sheet thumbnails to full instances of Freewheel, as well as embedding interactive views of the same sheets. (The HTML source for this page is posted on my blog – it’s not complicated, but too long to include here.)

Embedding_and_linking_freewheel

Figure 14 – embedding and linking to Freewheel in a custom web-page

The code that defines the above page could actually be generated manually – and that’s the next bit of fun… :-)

Using AJAX you can call web services from your client code: there are limitations as to what you can do (especially with regards to security limitations accessing web services across domains - which will make a great advanced topic for my blog), but this should give you a rough idea of what’s possible. In the below sample we query the number of sheets for a particular DWF, and use DHTML to generate the tags that allow us to view the content, as in the above hard-coded sample:

Blank_freewheel_generator

Figure 15 – our Freewheel generator on load

Completed_freewheel_generator

Figure 16 – our completed Freewheel generator

October 30, 2007 in AJAX, DWF, Freewheel, HTML, Training | Permalink | Comments (7) | TrackBack

AU Handouts: Enriching Your DWF™ - Part 1

Introduction

This session focuses on technologies that can be used to view and access DWF content downstream from Autodesk’s design products. Yesterday’s session focused on DWG – we’re going to take the model containing 3D solids that we created during that session and publish it to DWF, adding custom metadata. We can then look at how to harness this data in lightweight applications, whether to access it non-graphically or to view it.

Firstly, why are we using 3D solids in this example? The choice was somewhat arbitrary – the point is really to demonstrate the ability to access properties of objects stored in a DWG file without AutoCAD running – but it does suit our overall purpose for a few reasons:

  1. As 3D entities, 3D solids allow us to evaluate the 3D capabilities of the viewing technologies we’re looking at.
  2. While they have precise geometric properties (such as volume), as DWF is not a double-precision format we’re going to focus on accessing data of a less precision-oriented nature: the solids’ materials.

A quick word on the programming technology used in this demonstration. The code samples are in a mixture of languages: the AutoCAD .NET sample that adds metadata is in C#, the downstream DWF Toolkit sample is in C++ (for the DWF Toolkit component) and in VB.NET (for the user interface), while the Design Review and Freewheel samples are in HTML.

These handouts, along with the sample projects demonstrated within them, have been posted to my blog: http://blogs.autodesk.com/through-the-interface. Only significant portions of code will be highlighted in this document, and even those should not need to be typed back in. :-)

Creating DWFx files

In AutoCAD 2008, the PUBLISH command creates DWF files. In the future, however, Autodesk will increasingly publish to the DWFx format, one which more based on industry (particularly Microsoft) standard technology. For more information on DWFx, search for it on the Autodesk website, and search for XPS on Microsoft’s website.

To create DWFx files from AutoCAD 2008 today, you need to download and install the DWFx Printer Driver, which can then be selected from the PLOT dialog:

http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=9124615&linkID=9240618

AutoCAD’s PLOT mechanism does support multiple sheet printing, but won’t let you plot both 2D and 3D sheets to the same file (unlike the PUBLISH command, which does).

The other technique for creating DWFx files is to save DWFs from Design Review 2008 as DWFx. This approach has the benefit of including any 3D and metadata content in the resultant DWFx file.

Publishing DWF and plotting DWFx from AutoCAD

Now we’re going to take a quick look at the contents of DWF and DWF files. For the purpose of this example, we’ll simply PUBLISH our 2D layout to DWF and PLOT it using the DWFx driver to DWFx.

Let's launch PUBLISH and remove the modelspace sheet, and then hit the “Publish” button, selecting a DWF file as the destination (in our case solids-Layout1.dwf):

Plotting_a_single_sheet_dwf_from_au

Figure 1 – publishing a single-sheet DWF file from AutoCAD

Now we launch the PLOT command and select the DWFx driver, using it to PLOT our 2D layout to a DWFx file (in our case solids-Layout1.dwfx):

Plotting_dwfx_from_autocad

Figure 2 – plotting a single-sheet DWFx file from AutoCAD

So now we have two files, solids-Layout1.dwf & solids-Layout1.dwfx. To look at their contents, we rename them to .zip and open them with WinZIP (both DWF and DWFx are package formats which are implemented as ZIP files of different types of data):

Contents_of_our_simple_dwf_file

Figure 3 – the contents of our DWF file

The interesting piece of our 2D DWF file is the .w2d file. If we extract it and open it in Notepad, we can see it’s contains both ASCII and binary information:

Contents_of_our_w2d_stream

Figure 4 – the contents of the W2D stream of our DWF

The big change between DWF and DWFx is the move away from the W2D format (which harks back to the days of the Whip! format) and adopting the more modern XML-based XPS format.

Let’s take a look at our DWFx file, now:

Contents_of_our_simple_dwfx_file

Figure 5 – the contents of our DWFx file

We can see straight away that there’s more to it: to start with there are more files included (and the DWFx file is 16KB while our DWF file is 8KB, but the ratio shifts as the files get larger – the overhead in this example is high relative to the amount of content we’re storing). The interesting file is the selected XML file – let’s load that into Internet Explorer to view it:

Contents_of_our_w2x_stream

Figure 6 – the contents of the W2X stream of our DWFx

This XML content defines the 2D geometry in our DWFx file, and is read by the XPS Viewer when we load it.

That’s it for our brief look at the DWF and DWFx formats. We could certainly go into greater depth – especially when it comes to the storage of metadata and 3D, but this is left as an exercise for the reader.

Publishing additional metadata to DWF files from AutoCAD

Now we’re going to take a look at the more advanced capabilities of the PUBLISH command in AutoCAD. Our DWG file contains 3D content in the modelspace and 2D content in its paperspace layout, and we ideally want a DWF file containing both. Not only that, but we’d like to attach metadata to both our 2D and 3D geometry.

We’re going to use an AutoCAD .NET module to attach this information. Here’s the C# code:

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.Publishing;


namespace DWFMetadata

{

  public class SolidsPublisher : IExtensionApplication

  {

    private bool mbPublishingTo3D = false;


    public SolidsPublisher() {}


    public void Initialize()

    {

      // Register for publishing events


      Publisher pb = Application.Publisher;

      pb.AboutToBeginPublishing +=

        new AboutToBeginPublishingEventHandler(

          OnAboutToBeginPublishing

        );

      pb.BeginEntity +=

        new BeginEntityEventHandler(

          OnBeginEntity

        );

      pb.BeginSheet +=

        new BeginSheetEventHandler(

          OnBeginSheet

        );

    }


    public void Terminate()

    {

      // Unregister from publishing events


      Publisher pb = Application.Publisher;

      pb.AboutToBeginPublishing -=

        new AboutToBeginPublishingEventHandler(

          OnAboutToBeginPublishing

        );

      pb.BeginEntity -=

        new BeginEntityEventHandler(

          OnBeginEntity

        );

      pb.BeginSheet -=

        new BeginSheetEventHandler(

          OnBeginSheet

        );

    }


    // Although an empty handler, responding to

    // this events allows the subsequent ones

    // to fire


    void OnAboutToBeginPublishing(

      object sender,

      AboutToBeginPublishingEventArgs e

    ){}


    // Check whether we're publishing to 2D or 3D


    private void OnBeginSheet(

      object sender,

      PublishSheetEventArgs e

    )

    {

      mbPublishingTo3D = e.PublishingTo3DDwf;

    }


    // This event does the real work


    private void OnBeginEntity(

      object sender,

      PublishEntityEventArgs e

    )

    {

      try

      {

        Solid3d solid = e.Entity as Solid3d;

        if (solid != null)

        {

          if (mbPublishingTo3D)

          {

            // Adding 3D metadata is easy


            e.Add3DDwfProperty(

              "Material",

              "Name",

              solid.Material

            );

            e.Add3DDwfProperty(

              "Identity",

              "Handle",

              solid.Handle.ToString()

            );

          }

          else

          {

            // 2D is more complicated...


            ObjectIdCollection objIds =

              new ObjectIdCollection();

            System.Int32 nodeId =

              e.GetEntityNode(

                e.Entity.ObjectId,

                objIds

              );

            if (nodeId <= 0)

            {

              // Create node with next sequential number

              // and a unique name


              nodeId =

                e.GetNextAvailableNode();

              string strUnique =

                e.UniqueEntityId;

              string nodeName =

                "ASDK" + strUnique;

              DwfNode node =

                new DwfNode(nodeId, nodeName);


              // Create a string property in

              // the Material category


              EPlotProperty matprop =

                new EPlotProperty(

                  "Name",

                  solid.Material

                );

              matprop.Category = "Material";

              matprop.Type = "string";


              // Create a string property in

              // the Identity category


              EPlotProperty handprop =

                new EPlotProperty(

                  "Handle",

                  solid.Handle.ToString()

                );

              handprop.Category = "Identity";

              handprop.Type = "string";


              // Create a property bag, containing

              // the properties and references


              EPlotPropertyBag bag =

                new EPlotPropertyBag();


              // This should set the ID of the property bag,

              // to be used in the property definition


              bag.Id = nodeName;


              // Add it to the object/instance references


              bag.References.Add(nodeName);


              // The properties themselves needs adding


              bag.Properties.Add(matprop);

              bag.Properties.Add(handprop);


              // Add properties and relationships to the DWF


              e.AddPropertyBag(bag);

              e.AddNodeToMap(

                e.Entity.ObjectId,

                objIds,

                nodeId

              );

              e.AddPropertiesIds(bag, node);

            }

          }

        }

      }

      catch (System.Exception ex)

      {

        Document doc =

          Application.DocumentManager.MdiActiveDocument;

        Editor ed = doc.Editor;

        ed.WriteMessage("\nException: " + ex.Message);

      }

    }

  }

}

Once we build this into a managed assembly we can simply load it with NETLOAD – the module initialization takes care of adding the event handlers into the publishing system, so there’s no need to call a command.

Now let’s launch the PUBLISH command and create our DWF file.

AutoCAD’s PUBLISH command allows us to generate DWF files that contain both 2D and 3D data (this is not possible using PLOT – it has to be PUBLISH). All we need to do is set the Model sheet to be a “3D DWF”:

Publish_dwf_from_autocad

Figure 7 – setting 3D content in AutoCAD’s PUBLISH dialog

Once we hit the “Publish” button and select our DWF file (solids.dwf, as that’s the name our embedded viewing sample will look for later).

We can now load the DWF file in Design Review and take a look at the 3D and 2D content.

3d_dwf_content_with_metadata

Figure 8 – 3D DWF content with metadata in Design Review

We can see that as we select a spherical object in the model, we can see the associated metadata in the “Properties” view on the left. The key thing for this demo is that we have identical “identity” metadata attached to the 2D content, so we can relate the two views.

2d_dwf_content_with_metadata

Figure 9 – 2D DWF content with metadata in Design Review

Sure enough, we see the same “material” and ‘identity” metadata associated with objects in both 2D and 3D content of the DWF.

Before we move on to using the DWF Toolkit to mine the content, let’s quickly Save As DWFx from Design Review 2008 and see the capabilities of the XPS Viewer.

Save_as_dwfx_from_design_review_200

Figure 10 – Save As DWFx from Design Review 2008

The file created (solids.dwfx) is actually about the same size as the equivalent DWF file (solids.dwf), but that’s also because the 3D and metadata content is implemented in the same way (as XPS doesn’t currently support either).

When we load it into the XPS Viewer (by browsing to it from Internet Explorer, assuming you’ve installed the XPS Viewer from http://www.microsoft.com/whdc/xps/viewxps.mspx or are using Vista, which has it pre-installed), you see a basic interface for 2D content:

Xps_viewer

Figure 11 – using the XPS Viewer to view our DWFx file

Note that our initial 3D sheet is replaced by one pointing us at the Design Review download location, as the XPS Viewer doesn’t currently support 3D content.

October 26, 2007 in AutoCAD, AutoCAD .NET, DWF, Training | Permalink | Comments (3) | TrackBack

"AutoCAD: 10 easy ways to crash your AutoCAD addin" webcast recording available for download

The recording of the October 4 session from the AutoCAD Development Masterclass series, "AutoCAD: 10 easy ways to crash your AutoCAD addin", has been posted here.

I will let you know as soon as the recording of the October 18 webcast, "AutoCAD: .NET for LISP Programmers", has been posted.

Enjoy! :-)

October 26, 2007 in AutoCAD, ObjectARX, Training | Permalink | Comments (1) | TrackBack

AU Handouts: There's More to .DWG Than AutoCAD® - Part 3

[This post continues from part 1 and part 2 of this series.]

Building a full editing product using AutoCAD OEM

Now we’re going to take our AutoCAD .NET module from the beginning of the session and build a complete CAD package around it.

AutoCAD OEM allows you to build a custom-branded version of AutoCAD, with the subset of AutoCAD’s own features and additional functionality you choose to build in. A key feature of AutoCAD OEM is its security layer, which will stop any module being loaded that has not been built in by design. By limiting its extensibility – and allowing a subset of standard functionality to be enabled – ISV (Independent Software Vendor) partners are able to sell products based on AutoCAD OEM at a lower price-point.

This is, for example, how we build AutoCAD LT and DWG TrueView: they are both “cut down” versions of AutoCAD built using the AutoCAD OEM engine.

So let’s take a look at how to create an AutoCAD OEM product. We want to build an application that only contains AutoCAD’s 3D editing & visualization functionality, with our additional application logic added, to provide some in-built analysis of our models.

To get started, we launch the OEM Make Wizard. This tool depends on some Visual Studio environment variables to be set, so the simplest way is to launch it from a Visual Studio 2005 Command Prompt. I typically set the working directory for the command prompt to the root AutoCAD OEM folder (in my case “C:\Program Files\Autodesk\AutoCAD OEM 2008”) and then launch the tool by typing in “toolkit\oemmakewizard”.

On the first page of the Wizard we specify a name for our product. We’ll use “Solids”: this short name will be used for the executable name, for instance (i.e. Solids.exe, rather than acad.exe).

Oem_make_wizard_begin_session

Figure 10 – starting a project with the OEM Make Wizard

On the next page we specify some additional information, such as a longer product name and version numbers. We also need to enter a keycode, taking the form MMSSSSSDD, where MM is the current month, SSSSS is the last 5 digits of your AutoCAD OEM serial number, and DD is the current day.

Oem_make_wizard_project_information

Figure 11 – entering project information in the OEM Make Wizard

Next we specify the standard commands we want enabled. There are different levels of command support – None, Internal Use, Full and Redefine. Internal Use means we will call it programmatically, but don’t want the command directly usable by the user, and Redefine means we want the command to be usable but we will provide our own implementation. It should be obvious what None and Full mean. :-)

Oem_make_wizard_autocad_commands

Figure 12 – specifying the AutoCAD commands to expose with the OEM Make Wizard

Now we add our custom module. Application modules need to be bound to a particular OEM product, if they are to be loaded by it. This is essentially where we tell AutoCAD OEM’s security layer to allow specific modules to be loaded. This step also lets us specify a location to copy the application module to. .NET modules don’t need to be built specially, while ObjectARX modules need to be built against a special version of the ObjectARX SDK.

Oem_make_wizard_your_modules_2

Figure 13 – adding your own modules with the OEM Make Wizard

Then we need to specify the commands that our module implements – in our case it’s SD and SD2.

Oem_make_wizard_your_commands

Figure 14 – exposing your commands with the OEM Make Wizard

To enable Automation to work from outside our application – especially to embed it as an ActiveX control, which we will do later – we need to assign GUIDs for a number of interfaces. This is handled automatically by the tool.

Oem_make_wizard_automation

Figure 15 – defining an automation interface with the OEM Make Wizard

Next we customize the look & feel of our application, firstly by assigning a new splash screen, about box image and background image for our application frame.

Oem_make_wizard_custom_images

Figure 16 – specifying custom splash screen and about box images with the OEM Make Wizard

We can also choose to disable certain user interface elements, such as toolbars and dashboards. This is clearly important to do if we’re disabling standard AutoCAD functionality.

Oem_make_wizard_toolbar_and_dashboa

Figure 17 – turning off user interface components with the OEM Make Wizard

The same applies for AutoCAD features – we can disable various parts of AutoCAD’s standard functionality from this page.

Oem_make_wizard_autocad_features

Figure 18 – turning off AutoCAD features with the OEM Make Wizard

Certain file associations used by AutoCAD are not relevant for our AutoCAD OEM application. DWG is needed, of course, but many others are not.

Oem_make_wizard_file_extensions

Figure 19 – turning off file associations with the OEM Make Wizard

Finally – before we build – we can change the standard application icons (for the frame, each document, etc.) to be more representative of our application look & feel.

Oem_make_wizard_change_icons

Figure 20 – changing your application’s icons with the OEM Make Wizard

Now let’s build the application. This can be time-consuming, but the good news is that many changes do not require a full rebuild. You can decide which parts of the build should be rebuilt – deciding exactly which parts comes with experience, or you can always choose to perform a full rebuild, of course.

Oem_make_wizard_build

Figure 21 – building your application with the OEM Make Wizard

Oem_make_wizard_build_complete

Figure 22 – our OEM Make Wizard build is complete

And here’s our running custom-branded OEM product:

Autocad_oem_application

Figure 23 – our running AutoCAD OEM product

Currently the custom .NET module that implements our SD and SD2 command can be loaded using the standard NETLOAD command inside our AutoCAD OEM product. To make life easier we’re now going to implement demand-loading. The attached Registry file, when merged, will cause our AutoCAD OEM product to load our custom module when either the SD or the SD2 command is invoked by the user:

Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\SolidsSystem\R11\SOLIDS-6001:409\Applications\SolidsAnalyzer]

"DESCRIPTION"="SolidsAnalyzer"

"LOADCTRLS"=dword:0000000c

"LOADER"="C:\\Program Files\\Autodesk\\AutoCAD OEM 2008\\oem\\Solids\\solidsanalyzer.dll"

"MANAGED"=dword:00000001


[HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\SolidsSystem\R11\SOLIDS-6001:409\Applications\SolidsAnalyzer\Commands]

"sd"="sd"

"sd2"="sd2"

The LOADCTRLS value above is “C” – hexadecimal for 12. This means that we’re saying the module will be loaded either “on load request” (8) or “on command invocation” (4). We could change this value to “2” (which is the same in decimal as in hexadecimal :-) if we wanted to load the module automatically “on startup”.

For more information on this topic, search for “demand loading” on the Through the Interface blog, or type in this URL:

http://through-the-interface.typepad.com/through_the_interface/2006/09/automatic_loadi.html

Further streamlining the user interface by embedding our AutoCAD OEM product

For our final demonstration in this session, we’re going to embed the AutoCAD OEM product we’ve just built into a .NET application.

Just as we added the DWG Thumbnail and DWG TrueView control to our Visual Studio Toolbox, we can now add the ActiveX control for our solids-editing product.

Adding_the_autocad_oem_control_to_o Autocad_oem_control_in_our_toolbo_2  

Figure 24 - adding our AutoCAD OEM product’s control to your Visual Studio Toolbox

Once we’ve embedded the control in our form (MainForm), with buttons for browsing to a file (BrowseButton), analyzing the drawing (AnalyzeButton) and closing the application (CloseButton), we can add some code behind the buttons:

Public Class MainForm


  Private Sub BrowseDwgFile_Click _

    (ByVal sender As System.Object, _

    ByVal e As System.EventArgs) _

    Handles BrowseDwgFile.Click

    Dim dlg As New System.Windows.Forms.OpenFileDialog()

    dlg.InitialDirectory = "c:\"

    dlg.Filter = "Dwg files (*.dwg)|*.dwg|All files (*.*)|*.*"


    If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then

      Dim