Thursday, February 28, 2008

Revit 2009 API: New Creationism

In the beginning, there was the API - and you could create virtually nothing. Then came the basic elements, then the structural elements... Release by release, Autodesk is slowly making progress to the point where you can make a wide variety of elements through the API.

Every year people want to know - "what new element types can I create that I couldn't create in the past?".



What's Newly Possible to Create in 2009?


  • Area

  • AreaViewPlan

  • AreaTag

  • AreaBoundaryLine

  • Space (MEP)

  • SpaceTag

  • SpaceBoundaryLine

  • RoomBoundaryLine

  • CurtainSystem

  • ExtrusionRoof

  • FootPrintRoof

  • Gutter

  • Fascia

  • FoundationWall

  • Electrical System (MEP)

  • SlabEdge

  • SpotCoordinate

  • SpotElevation

  • Truss

  • Zone (MEP)

  • Wire (MEP)

So that's a good set of new elements, right?

While it's not necessarily enough to generate an entire design from scratch, I've always been of the opinion that with a system like Revit you're better off with the "template" approach for "end-to-end" automation anyway.

There's definitely enough there to make some intelligent tools to automate specific aspects of the design.


Batch Creation


If you tried creating a large number of elements in 2008 or before, you may have noticed that it was rather, well, slow. Avatech once tried to automate a point cloud into Revit 2008 - and I think the application is still running many months later :). Autodesk improved on this during 2008 with the introduction of a SuspendUpdate object, which addressed part of the problem (the problem that Autodesk was fully updating the Revit model after each element was created). This was improved again in 2008 SP2.


In 2009, Autodesk has gone down a different path to help with performance. They have introduced a number of new methods which can batch create a variety of specific types of elements.
  • Family Instances

  • Rooms

  • Spaces

  • Text Notes

  • Walls (Profiled or Rectangular).

The new methods take a List of data to create each element.


For example, the NewRooms() method looks like this:


List<Autodesk.Revit.Creation.RoomCreationData> roomData =
new List<Autodesk.Revit.Creation.RoomCreationData>();

// get the current view's level
Level myLevel = doc.ActiveView.GenLevel;

// create arbitrary rooms at 10 foot intervals
// (I hope there are walls there to separate!).


for (int i=0; i < color="#3366ff">Autodesk.Revit.Creation.RoomCreationData
(myLevel, new UV(i * 10.0, 0))
);
}


ElementSet rooms = doc.Create.NewRooms( roomData );


//////////////////////////


All in all, there's some good additions to Revit's creation-ability.


-Matt


No comments: