Thursday, April 22, 2010

Revit 2011 API: What’s New in Element Creation

(part of our ongoing series)
Each new version, I go through what is new in the specific API area of element creation. Every CAD API has some logical divisions, from information retrieval, to element creation, to interactivity – and you can tell from how strong each area is what the factory’s focus is in the API.

Revit’s start in this area was weak – the API was more about finding elements and updating parameters than actually creating new elements and geometry. In recent releases, Revit really played catch up – I believe it now supports 101 different element creation methods.

So what’s new in 2011 in this area: in short, not much… This was not an area of focus in 2011, so there’s only a few new things in this specific area:

  1. NewTruss() – now available in architecture
  2. NewRebarType()
  3. NewRebarHookType()
  4. NewRebarCoverType()
  5. FaceWall.Create()

The last one is of the greatest interest to me personally. This enables you to create a wall based on a face (typically a face that is on a mass element). This is an advanced technique used in Revit to create complex wall shapes.

Two other items deserve honorable mention here as well:

  • UIDocument.PromptForFamilyInstancePlacement() – while not technically a “Element Creation” capability, it opens up some significant doors to more interactive design applications within Revit – by letting the end-user help the developer place the family instance visually.
  • SolidSolidCutUtils – A new utility class to help with doing solid-to-solid cuts in the modeling environment. This is typically used either for GenericForm kind of family solids or family instances.

All in all, while this category doesn’t seem like it got much attention in 2011, the fact is that with 101 element types that can be created, it has attained a certain level of maturity. For example, if I scan the Home ribbon in 2011 – it is possible to create almost everything that is available on that toolbar (I think the exceptions are: Ceiling, Model Group (you can’t create a new one), Railing, Ramp, Stairs. That’s really not too bad – and the remaining ones are a little on the obscure/complex side.

So let me hear from you by comments? Are you really waiting for one of the missing elements that can’t be created? or are you just reluctant to do API work with geometry creation until it supports 100%? How many different kinds of elements are YOU creating in your app?

8 comments:

Sage said...

Being a long time AutoCAD techie one of my favorite tricks was to create insertion icons. I'd have a nail button for example and that would load up a nail and dump me into the insert command. I'd just have to pick where I wanted to place that nail. One button press and where i want to place it. Easy... er... cheesy... (ok that was cheesy)

Now with Revit I've always wanted to recreate this. Up till now I've never seen the api call to allow me to drop the detail component in. Sure I could load it and dump it in the middle of the screen. At that point I'd have to go get it and move it around.

Do you see that in the 2011 version of the api? I'm thinking that UIDocument.PromptForFamilyInstancePlacement might just do this.

Thanks.

Sage

Matt Mason said...

Sage,

Yes! That's now possible, in three different ways!

The PromptForFamilyInstancePlacement will do it (much like the interactive Revit way). It's also possible to use "Selection.PickPoint" and get back a location in the current (2D) view - and place based on that.

And finally, there's also pickObject (which can give you back not just the element you selected on, but the location where you picked - and allowing you to filter based on the proper situation - for example, only vertical faces of a wall that are not the end faces).

-Matt

So there's a lot of potentially cool tools that can be developed given those two pieces.

Jeremy Tammik said...

Hi Matt,

You missed a little piece of the new Revit API element creation functionality:

http://thebuildingcoder.typepad.com/blog/#10

Cheers, Jeremy.

Matt Mason said...

Jeremy,

Good catch!
Now that they're starting to hide things in static methods, it's harder to discover them!

Thanks,
Matt

Jeremy Tammik said...

Hi Matt,

The intention is to make it easier, at least while developing, and searching for the creation method ... it should help to have it as a member of the class you want to create an instance of :-)

Cheers, Jeremy.

Matt Mason said...

Jeremy,
Very true - and I think once I've adjusted, it will be natural.

But at the moment, there's only about 3 classes that do it that way (FaceWall, Conduit and AnalysisDisplayStyle are all that come to mind)... so there's not quite yet enough classes to make it my first instinct :).

-Matt

skeletank said...

Are there any means to create a Callout in the REVIT API? I've noticed that when I create a callout through the UI two things are created, an element of category OST_Views and an element of category OST_Viewers. I can create the view (which is the OST_Views) using Document.Create.NewViewPlan but I haven't been able to figure out how to create the callout annotation which is the OST_Viewers element.

Matt Mason said...

No, I think you've hit the wall there...