Saturday, March 14, 2009

What’s New in the Revit 2010 API: Geometry

(Part of the What’s New in the Revit 2010 API series)

The Geometry area of the Revit API has a few interesting and helpful enhancements in the 2010 version.

image Probably the most obvious of the enhancements were made to support Revit’s new conceptual massing capabilities.


While there was previously a HermiteFace class to represent the surface – we now have a HermiteSpline element for the splines that can be created (which will probably result in many more HermiteFaces as well – since it only takes one button to go from spline to face).

The HermiteSpline exposes its control points and tangent vectors (nice touch). WARNING: For those of you who have been using Tessellation – like we have on our Earth Connector application – be prepared for an explosion of points as Revit Users start using splines. The 5-point spline shown above tessellated into 287 points… (I probably have to start investing some mental energy in a “reduce” function – because that’s pretty heavy!).


As I joked about in one of the previous posts – Autodesk has finally broken down and added the Point concept to Revit (yes, yes – the XYZ class was there before – but Points are now first class geometric objects).

The reference points in the picture above are part of the spline, but it is possible to create standalone ReferencePoint elements – and the geometry extracted for the reference point is a Geometry point.

I have not yet figured out why it’s important to have a point in the geometry class (since you can get the location directly from the element) – but I’m sure that there is a good reason (consistency, if nothing else, I suppose).

Making Life a Little Easier for You

Historically if you dealt with geometry in the Revit API, you had to brush up on your linear algebra in order to deal with Transformation matrices… For example, a chair might be modeled within a family centered on the 0,0,0 point – but then it gets placed 100 times into a project way out in space. Every instance has a transformation matrix that gets you from the “internal” geometry locations – also known as the “SymbolGeometry” – out to the actual geometry location in the project.

It was even worse when items are nested a few levels deep… I know that, for example, stairs have railings and railings have balusters – and balusters gave me fits for quite some time, being a good number of levels deep.

Autodesk started making this better a couple of releases ago – making it easier to get the transformed version of things – and they’ve taken it another step now.

  • Instance.GetInstanceGeometry()
  • Instance.GetSymbolGeometry()

(Instance is the Geometry class which represents things like FamilyInstances, and other elements where you need to dig into the definition of things). Both of these methods can optionally take a transform matrix to transform – or just give you the easy answer.

The Hit Reference

I mentioned in “Very Spatial APIs” that the Reference class has been upgraded, mainly to provide the additional information retrieved when shooting rays through elements. The new properties:

  • ProximityParameter (how close the hit is to the origin)
  • Element (the element that was hit)
  • ElementReferenceType:
      • MESH
      • CUT_EDGE
      • INSTANCE
      • FOREIGN (from the docs: “The reference is to geometry or elements in linked Revit file.”)
      • SURFACE
      • LINEAR (curve or edge)
  • GeometryObject (the geometry intersected)
  • Transform (of an instance, if that’s what was hit)
  • UVPoint (U,V parameters of the face, if that’s what was hit)


This is yet another area with modest but solid improvement in the API in 2010.

What’s New in the Revit 2010 API: Events

(Part of the What’s New in the Revit 2010 API series)

The Event section of the API is one area that I believe developers have been hoping for years to see more… In 2010, Autodesk re-writes a bunch of what is there, adds a few more interesting events – but probably leaves out what you were hoping for…

Before and After

The biggest change, both for the re-written events and the new events is that they can receive callbacks either “before” the action or “after” – which is a very nice, mature feature for events. The “before” events enable you to either (1) fix the model before it is saved/printed/etc OR (2) stop the process and ask the user to do something before the action can be performed.

NOTE: for those of you who are thinking immediately about having “alternative interfaces” for something like Document.SaveAs – I think you’ll be disappointed. So far as I can see all of the “before” events are still fired after the user has completed the dialog (i.e. chosen the new SaveAs target file) – but before it actually happens.

User-Driven and API-Driven

I’m not sure that this was the case in the past – but there are notes with the 2010 release that indicate that the events will fire not just when triggered by interactive usage – but also when triggered by the API. I’m not 100% sure if I love that (once we developers all start using them at the same time) – but we’ll see.

Re-written Events

The following events have been re-implemented:

  • Document Creation
  • Document Opening
  • Document Saving
  • Document Save As
  • Document Closing
  • DialogBox showing (Revit 2010 generally uses the newer style “TaskDialog” from WPF, rather than the old-school “MessageBox” of the last 15 years)

The New Events

The new events are:

  • File Export
  • File Import
  • View Printing
  • Document Printing
  • View Activating
  • Document Save to Central

The last one, saving a document to the central file – has some interesting options – including being able to see the exact properties that have been used for the operation, including:

  • Compact Central File
  • Relinquish Borrowed Elements
  • Relinquish Family Worksets
  • Relinquish Project Standard Worksets
  • Relinquish User Created Worksets
  • Save Local File

That said, alas, they are read-only.

In Summary

I know you were hoping for an element-level event. Autodesk knows that you’d like to have it – but there are apparently some complexities and pitfalls to giving us this power (not the least of which is that we could probably cause never-ending cascading update loops).

All in all, though – the events took a good step forward in terms of the maturity of the API. They’re better thought out than before, and they’ll get more usage.

Monday, March 02, 2009

What’s New in the Revit 2010 API: Import/Export

(Part of the What’s New in the Revit 2010 API series)

Revit 2010 introduces a number of nice enhancements to Importing and Exporting in general – and best of all (for developers, at least) – all of the new capabilities are also available through the API.

The ADSK File Format

One of the new exciting capabilities in 2010 product line revolves around a new file format called an ADSK file (Autodesk Exchange File). This is essentially a zip file, but it contains all the geometry and data that are needed to support DIFFERENT intra-Autodesk software workflows (including, for example – Revit to Civil3D and Inventor to Revit).

Export BuildingSite

The BuildingSite export gathers a wide variety of information useful primarily to Civil3D users, and puts it together in a package that’s easy to transfer.

The content includes:

  • dwg files for the footprint, building shell, site plan and property lines.
  • Data such as:
    • Gross Building Area (based on a selected AreaPlan)
    • Building Model data (doors, floors, roofs, etc)
    • Project Information, including:
      • Location information
      • Building Type
      • Total Occupancy
      • Area per person
  • Preview Images

All in all, the amount of XML data is significant in there – so I think we’re just hitting the highlights of what is potentially transferred here…

The API export gives a few options, and I think between what it picks up automatically from the model and what you can specify, you have access to pretty much everything.

Import from Inventor

Import from Inventor is another incredibly important workflow in the greater scheme of things – particularly for the MEP side of things. The ability for manufacturers to model their content in Inventor (with as much detail as they want) – but then to easily produce lower-detail models for use in Revit (including MEP connectors) – that’s powerful.

I haven’t gotten Inventor 2010 installed yet – so I haven’t tried out the export side. The import side seems to be pretty minimal (both in the UI and in code). But the capability is there.

(NOTE: I can’t recall if these are DWG or ACIS solids – but I’m pretty sure it’s not a “new” method of exchange – it’s a better-controlled, better-wrapped version, which includes additional properties and the MEP connectors – but the geometry is probably on the “heavy” side compared to native Revit).

Export to DGN

New with Revit 2010: export to Microstation DGN format. The export options include:

  • Export Solids (ACIS or Polymesh)
  • Layer Mapping (a layer setting or file)
  • DGN Template File

Extract PartAtom

This is equivalent to the new “Publish –> Share with Autodesk Seek” capability. The capability in the UI packages up a piece of content, along with XML to fully describe the types, the parameters, etc – all a part of the PartAtom specification used by Autodesk Seek.

The API version of this only produces the XML file – you’ll have to do the rest yourself. NOTE: This method, ExtractPartAtomFromFamilyFile is on the Application class (not the Document or Family class).

Export GBXML

The GBXML export is much improved in the 2010 User Interface (shown below).


The most important new capability to note here is the “Export Complexity” option. This option will control how much detail is exported to the GBXML model from your Revit model – ranging from only the basics, to how “shading surfaces” are handled, to whether curtain wall mullions are counted as shading surfaces.

The capability for the API to export GBXML was introduced in the prior version – but this has been updated to include the all-important complexity option.

NOTE: This is technically not a change to the “Export” method for GBXML, but a change to the GBXMLparamElement which defines the export options.

Import GBXML

This is a fascinating new addition to the Revit MEP package – the ability to read GBXML back into Revit. While I’m sure that there is probably more workflows that I haven’t quite grasped yet, just being able to use Revit as a GBXML viewer (or see what went out the door as GBXML) seems very useful.

The API exists for import, however, there are currently no options.

New DWF Export Options

The API has been restructured a little around DWF export – shaping up for more robust options in the future (for example, there’s now separate options classes for DWF2D, DWFX2D, DWF3D and DWFX3D) – although they’re mostly the same between DWF and DWFX at present.

In the 2D DWF/DWFx export, they’ve added support for controlling:

  • Image Format (compression level)
  • ImageQuality
  • PaperFormat (size)
  • Paper Orientation (portrait or layout)

These additions will help fine tune the DWFs you can create.

Most of the Export Options (DWF and FBX) also now include a “StopOnError” option, so that it won’t keep going if it runs into a problem… sounds like a good idea! :)


Many of the enhancements to import/export are driven by the core 2010 product enhancements. But it’s so nice to see that they’re investing in keeping the API up with what’s new, rather than lagging a year or more behind.