Friday, December 28, 2007

Revit 2008 API: If you haven't seen it all, then there are still new features...

A couple years back, NBC or one of the other networks had a campaign for people to watch "re-runs", saying basically - "if you haven't seen it yet, then it's new to you". While I've written a decent amount about what's in the 2008 API and what's possible, I'm still stumbling into things I didn't think were possible.

Case in point: I've been reviewing the alpha version of the 2009 API (I think I'm allowed to say that - although I can't give any details) - but along the way in comparing it to 2008, I found a few things that were "new to me" - so I figured I would note them for other people...

Make more family types...
I had poked around at the concept of making new families and types - but it didn't seem like it was possible. While you can create a new Family from a template, it didn't seem like there was a method where you could create new types within the family....

The problem was that I was looking for something more explicit, like "CreateNewType()" - the other day I discovered you could do:

family.Symbols.Duplicate( ), where you can duplicate one of the existing types. That's something, at least!

Someone had asked on the AUGI message board last week whether it was possible to find elements within a family. My original thought was "not entirely" - I knew that you could find nested families and solids and voids - but I thought that was it. I happened to give it a quick look with the RvtMgdDbg tool, and noticed that the "Others" field in the family object has "everything else" which is defined inside the family (views, elements, etc).

Coping with Families
A ways back I had noticed that the FamilyInstance class had "AddCoping/SetCoping/RemoveCoping" etc - all working with other elements. I've finally had a chance to inquire what this is for... It's typically used for Structural beams (in fact, it may only work with items that are steel?) when beams have to come together at strange angles (this tells Revit that they should be joined in a Coping style).

View3D Sectionbox is modifiable
I've been lamenting for ages that the View objects are not really nicely modifiable in the Revit API - and that's still true. Someday we'll be able to control the view like with any other CAD system. But I did find one thing which I hadn't realized before - it looks like the Sectionbox in a View3D object is modifiable - which might mean that you could do some interesting automation. Someone had asked a while back if it was possible to get prints of each level in 3D at different phases. By modifing the section box dynamically - this would get pretty darn close.

Anyway - just thought I'd pass this on. Someone someday will Google for "Revit View3D", and this will come up and make their day.

Friday, December 21, 2007

Dumb Revit API Trick...

So I stumbled across something in the Revit API the other day. Probably impractical - but I figured I'd pass it on.

I'd been frustrated in the past with two aspects of Revit development (ok, far, far more than two - but I'm talking about two specific things in this context :) ).

- You can't change the active view in a Revit document.
- Although you can load a document or create a new document, it didn't do it VISUALLY... That is, it's done in Revit's memory - but it's only programmatic, the user never sees it.

Both of these things seem to limit what you could use the API to do - right?

Anyway, I was poking around with RvtMgdDbg, the object browsing tool provided to ADN members - and it has a few test utilities. I tried out the printing one (knowing that the printing API also has so many problems with it that it wasn't worth pursuing) - but I noticed something... views and models were changing on the screen in front of me.

That's when it hit me. If you want to change the Active View - Print the one you want.
If you want to "show" a document you've loaded - Print it.

It's about the dumbest workaround I've ever come up with (and that's saying something) - and it will probably lead to further deforestation - but hey, it works!

Actually, what we would really need to make this almost usable is some kind of "null printer" driver which doesn't actually do anything - it just sends the printer bits into the black hole. Even with that, and as desperate as I sometimes am for a workaround, that's probably not a scalable solution. Of course, you would also need Autodesk to provide a way of specifying that printer, which is not available in 2008 - we can hope for 2009.

Ah well - I figured I'd pass it on.