Saturday, February 21, 2009

What’s New in the Revit 2010 API: Very Spatial APIs

One of the most exciting areas of potential API development is checking the building… Whether trying to determine if the egresses are short enough, or whether there is a nurses station close enough to each room, or just understanding how buildings, floors and rooms are modeled – there are a lot of things to check for. Historically, these things have been hard to check for – it was far easier to just look at a drawing than to try and figure it out.

But all that is beginning to change with some neat new APIs in 2010, which give you some tools to help understand the building and spatial relationships between objects.

Shooting Rays

One of the classic CAD solutions to these kinds of problems is “shooting rays” through your model… That is, set a point and a vector, then see what that “ray” hits. This was kind of possible with some creative math prior to 2010 – but it’s both better and easier now in 2010.

The new mechanism:

ReferenceArray =
Document.FindReferencesByDirection( origin, direction, View3D)

The new method returns back an array of references – and the reference class has been upgraded to include:

  • Element
  • Type of Reference (Surface hit, Element hit, Edge, Foreign, Mesh)
  • GeometryObject of the hit
  • XYZ location of the hit
  • Distance of the hit from the origin (“Proximity Parameter”), UV location of the hit on a surface (if appropriate)

Important Note: The View3d that you specify controls a few things – first, if you’ve got elements or categories hidden, those do not seem to be “hit”… Also, remember that if you’ve got model phases, the ray will follow the phase of the view.

image

Still, it’s a great new feature for those who are trying to use the API for any kind of building analysis.

Where am I?

The other enhancements in the category of spatial awareness relate to being inside a particular architectural room or MEP space. If you want to test if a given point is in a known room or space, you now have:

  • Room.IsPointInRoom( xyz )
  • Space.IsPointInSpace( xyz )

Conversely – if you don’t know where a particular XYZ point is at all, you can ask:

  • Document.GetRoomAtPoint (xyz)
  • Document.GetSpaceAtPoint (xyz)

I think these enhancements are also critical… while FamilyInstances have long known which room they were in – these API enhancements give a great variety of additional power for analyzing buildings.

What’s New in the Revit 2010 API: Element Enhancements

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

As with each release of the Revit API, there are a ton of enhancements to the “Elements” area of the Revit API. Whether it’s new capabilities on existing elements, or new Element classes to make Revit elements more identifiable and understandable – enhancements here are a big deal.

Elements and Materials

One of the features I’m most excited about is the new Element/Material part of the API. In the past, trying to do material take-offs with the API was tough – especially if the designers were using Split Faces (which almost everyone does). You pretty much had to export out to ODBC or schedules to Excel in order to extract what you needed. But no more.

image This room floor has been divided by a split face – with one of the sides being carpet and the other tile.

In Revit 2010, every Element has a Materials property to show all the materials associated with an element. Further, you can call Element.GetMaterialArea( Material ) or
Element.GetMaterialVolume (Material)

to get the area or volume of material for that element. With this, people trying to do material take-offs through the API should be in far better shape!

Element Hiding

For a number of releases, Revit has supported the hiding of individual elements on a view-specific basis. While great for designers, it did pose occasional challenges for developers. Now, the API offers up:

Element.CanBeHidden ( View v )
Element.IsHidden( View v )
as well as:
View.Hide( Element e)
View.UnHide( Element e)

This should give developers powers similar to what you can do in Revit interactively (that fairness which every CAD developer yearns for :) ).

Family Enhancements

There are few enhancements with Family and FamilyInstance elements:

  • Family.IsInPlace (this was possible heuristically in previous releases – but it’s always better to make it obvious)
  • Family.IsCurtainPanelFamily (because of the special additional properties – it’s good to know this directly)
  • FamilyInstance.IsSlantedColumn (another situation where there are special additional properties)
  • FamilyInstance.Space  (similar to familyInstances knowing which Room they reside in, now they know which space they reside in – very useful for MEP families!)

New Element Classes

The following classes are new in 2010:

  • Alignment
  • AreaScheme (see below)
  • BasePoint
  • Control
  • CurveByPoints
  • CurveElement
  • DividedSurface (with an amazing amount of depth!)
  • Form (representing all of the Family solid content, and also with a huge amount of depth)
  • ImportInstance (used for DWG imports, etc)
  • ModelText
  • PointOnEdge
  • PointOnEdgeEdgeIntersection (I think you might need to have a PhD or be Russian to understand this :) ).
  • PointOnEdgeFaceIntersection
  • PointOnFace
  • PointOnPlane
  • ReferencePoint
  • ReferencePointArray
  • SpacingRule (structure and grids)
  • SweptBlend
  • SymbolicCurve
  • TopographySurface (with an “AddPoints” method, no less)

Areas

There appear to be a few enhancements to Area elements that are of note:

  • New AreaScheme element (this typically is set for “Rentable”, “Gross” but also apparently has some new BOMA settings for facilities management people)
  • Areas have a link to their scheme
  • ViewPlans have a link to the AreaScheme (where appropriate)

Dimensioning

Dimensions also seem to have some upgrades in 2010. In particular:

  • Dimensions have DimensionSegments
  • The “Locked” property (read/write) has been added

Other Miscellaneous Enhancements

A few others that I couldn’t categorize:

  • Blends now have access to Profiles, Offsets and VertexConnections.
  • CurtainGridLines now have ExistingSegmentCurves
  • Grid.ExtendToAllLevels method
  • GridNodes
  • GBXMLParamElement now has an ExportComplexity object associated with it which contains all sorts of things to control how GBXML is exported (including, for example, how to handle Shading Surfaces).
  • ModelCurve now exposes:
    • IsReferenceLine
    • SubCategory
    • TrussCurveType
    • Visibility
  • Mullion.LocationCurve
  • Opening exposes IsTransparentIn3D and IsTransparentInElevation.
  • Path3D.AllCurveLoops

Two that I’ll be writing about a little later:

  • Room.IsPointInRoom (XYZ)
  • Space.IsPointInSpace( XYZ )

A few items seem targeted at making it easier to get geometry references and planes:

  • Level now exposes a PlaneReference (to make things easier)
  • ReferencePlane.Reference
  • SketchPlane exposes:
    • Reference
    • IsSuitableForModelElements
  • View.SketchPlane


Wow. Again – there’s enough in these enhancements, new classes and more to keep us busy for quite some time.

What’s New in the Revit 2010 API: Element Creation

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

For some people, the measure of a CAD API is always how many different types of elements it can create. Revit got off to a slow start in this category, but it continues to get stronger.

In this release, the new Revit API capabilities seem divided into:

  • A significant amount of new MEP element creation
  • A little bit of new Structure / Rebar options
  • A significant amount of new capabilities around family content creation.
  • A few very interesting things around the new freeform geometry and divided surface modeling in Revit 2010.

All in all, Revit can now create 70-100 different types of elements (depending on how you count the family content-related things).

What’s New for MEP Creation?

Here are the new MEP-oriented creation capabilities:

  • Duct
  • Elbow
  • ElectricalSystem
  • FlexDuct
  • FlexPipe
  • MechanicalSystem
  • Pipe
  • PipingSystem
  • Cross Fitting
  • TakeOffFitting
  • TeeFitting
  • UnionFitting
  • Wire

(not being very MEP-savvy myself, I can’t add any real commentary to them other than to say it looks like an impressive list).

What’s New in Family Content Creation?

This whole area is new and exciting…

  • Solid Forms
    • Blend
    • Extrusion
    • ExtrusionForm
    • Form By Cap
    • Form By ThickenSingleSurface
    • Loft
    • Revolution
    • SweptBlend
  • Supporting Elements
    • Angular Dimension
    • ArcLength Dimension
    • Linear Dimension
    • Radial Dimension
    • Symbolic Curve
    • Control
    • Alignment (this looks interesting)
    • Vertex Index Pair (this is a construct which defines how different profiles in a blend link together, I believe)
    • Family Symbol Profile
  • More Elements
    • Openings
    • Model Text
  • Freeform Modeling / Surfacing
    • Curve By Points
    • Divided Surface
    • Reference Point

A Brief Story on Reference Points

A year or so ago I pinged Emile Kfouri, the Revit Platform Product Manager about why there were no “Points” in Revit (I can’t recall why I needed them – but I do know how old-time CAD people’s heads look like they’re going to explode when I say that they don’t exist). He said “Points are not BIM” – and I came to agree with the statement, in general (not that Lines are BIM – and they were prevalent in Revit still). In any case – while they’re not BIM, they are quite handy for building things – and it’s nice to see them in there.

A Few More…

Finally, there are a couple last additions and changes…

  • Rebars defined by RebarShapes
  • Hermite Splines (these are one of the building blocks of the new freeform modeling capabilities)
  • Plane from Curves
  • Topography Surface (Now this looks very interesting – just pass in an array of XYZ points and get back a surface? I haven’t had a chance to try it out yet – but it should be cool!)

image

Image: a spline-controlled surface with control points that can be dragged/modified.

Summary

All in all, this release presents a great deal of new capabilities around Element creation… certainly enough to keep most of us busy for the next year until Revit 2011 comes out!

Thursday, February 19, 2009

What's New in the Revit 2010 API: User Interface

From the (What's New in Revit 2010 API series).

As you may know, Revit 2010 brings the Ribbon-style User-Interface to the world of Revit. Similar to bringing the Ribbon to Microsoft Office or AutoCAD - this has far-reaching effects on how users will navigate Revit.

For better or worse, ExternalCommands and ExternalApplications will be shoe-horned into the new Ribbon concept.

How it Works

First, if you have any "Add-ins" of any kind, the "Add-in" tab is visible in Revit.

Second, any ExternalCommands which previously were on the Tools > External Tools menu are now on the Add-Ins menu under the "External Tools" pulldown-button.

Third, there are a number of "constructs" for how you can customize the ribbon. Unlike AutoCAD's WPF Ribbon UI, you are limited to just a couple of UI elements.



The key elements are:

  • RibbonPanel - creating an "area" to contain your application

  • Pushbutton - a single Pushbutton command

  • PulldownButton - a button which drops down a list of commands

  • Separator - basic separation

Both Pushbuttons and PulldownButtons can have large (32x32) icons and small (16x16) icons (not shown above). The large icon is always displayed on the button, while the small icon is only shown if the user adds the button to the "Quick Access Toolbar" - which is always available.

Autodesk also released a 29-page document describing how icons should be created to fit in with Revit (who knew it could be so complicated? :) ).

Existing Applications

The existing APIs that applications use to create both top-level menus or toolbars have disappeared - so you MUST migrate to this approach.

Summary Opinion

While I think that it's great that the Ribbon has come to Revit - I really like it... The UI straightjacket that we've been put in with the UI is a little tight... It would be nice if we could at least do stacked buttons like the rest of Revit.

(Editors Note: Stacked buttons, 2 or 3 high - was added in the API after this was written)

It's also a little unfortunate that everything external is confined to the "AddIns" tab - both because we used to be able to have "top-level" menus, but also because if you have a lot of applications loaded, the real-estate may get crowded.

What's New in the Revit 2010 API: Finally Families!






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





Probably the biggest single improvement to the Revit API in 2010 is a wide variety of enhancements to supporting Revit Families - and it's been a long time coming.


Until now, the support for families has been spotty - for example, you could open family files as documents - but you couldn't see the types inside them - or really do anything with them.

Autodesk has implemented a dizzying amount of capabilities to help with:

  • Analyzing Families

  • Creating new Families (geometry, parametrics and all!)

  • Reading and Writing Family Types, parameters, and even formulas

  • Ability to examine Families embedded in projects

  • Read/Write Family Element Visibility

  • Control the loading behavior of families
Personally, after doing a number of Family manipulation projects which had to be done with Journal Files - I'm excited to be back dealing with the API!

Enhanced Document class
The core concept of working with families in the Revit 2010 API is the improved "Document" class. The Document class still represents both Project and Family documents, but it has been enhanced with the following properties and methods:



  • EditFamily( family) - similar to context-menu Edit Family command

  • FamilyManager (provides access to the types, parameters, and formulas related to the family)

  • OwnerFamily - to deal with nested family components

The Family Manager is able to do a wide variety of tasks, including full control of adding, removing and renaming types, adding and removing parameters, and setting values and formulas.

Creating Solids



Creation of elements will be covered in more depth in another post - but suffice it to say there is an impressive list of things that you can programmatically create through the new APIs, including:


  • Extrusions

  • Blends

  • Sweeps

  • Loft

  • Model Text

  • Openings

  • Revolutions

  • Dimensions

  • and much more



Visibility Settings

For those of you who are not familiar with content building, one of the most critical topics to "get right" when building content is the visibilty settings:




Each element in a family has visibility settings - both which levels of detail it appears in as well as whether it appears in different types of views. These options are critical to building good content. For example, if you have intricate details in your family, consider if they should only be shown in "Fine" detail views. Also, if you have 3D solid content, one alternative is to NOT show the 3D solid in Plan views - instead, you would use 2D linework in Plan View. These approaches can make a SUBSTANTIAL difference in the performance of Revit - particularly as your building model grows.

While there had been undocumented parameter access to this information before, the new FamilyElementVisibility class makes this information easy to access for each element in a family.

Loading Control
If you've ever written an application that loads families into a project, you may have run into the problem of what happens when the family already exists in the project (particularly if you're using shared families). While the "DialogBox" event controls used to give a poor-but-workable method to suppress Revit's pop-up dialog boxes, the new loading methods give far better control over what happens.

The new LoadFamily method signature:

Family = Document.LoadFamily( string path, IFamilyLoadOptions options );
or
Family = Document.LoadFamily( Document familyDocument, IFamilyLoadOptions options);

The IFamilyLoadOptions, as implemented by the RevitUIFamilyLoad class, give you events for family loading as well as specific behavior control for whether to update the family, and whether to override parameters.


What Can You Do With All This?

There are a variety of capabilities that these features open to you... First of all, I suspect that a variety of new content tools will become available to better manage your content. If you manage a great deal of content, and need to make large-scale changes to content, these features will make it happen.

It IS possible now to extract project families back to RFAs - as well as doing better comparisons than previously possible between "embedded" families and standalone families.

Another big step for Autodesk - they now allow you to use the API insert a DWG file into a family. This had previously been deliberately disabled.

Hypothetically speaking, this means that you could possibly crank out thousands of families based on existing DWGs. But before you consider doing this - let me be among the voices saying - DON'T. Our research indicates that families created using DWG files are fundamentally terrible - they are "heavy", "slow", and "dumb". Almost all firms using Revit have discovered this - and are systematically removing these families from their library. Doing content correctly would be a great other post - and the API now gives you the tools to do things right... Please try to do the right thing!

-Matt

Wednesday, February 18, 2009

What's New in the Revit 2010 API: General Changes

(Part of the What's New in Revit 2010 API series)
In this post, we'll cover a few quick topics about general changes to the Revit 2010 API.

.NET 3.5 and Visual Studio 2008 SP1

First, the 2010 release has a new platform requirement for developing Visual Studio solutions - .NET 3.5 for users and Visual Studio 2008 SP1 for developers. What does this mean? Several things:


  • First, every user of Revit 2010 will have the .NET 3.5 Framework pre-installed, taking care of the pre-requisite issue.

  • We can leverage the new technologies available in .NET 3.5, including: Windows Presentation Foundation (WPF) for new look-and-feel, Language Integrated Query (LINQ) for easy access to data from databases, XML or the Revit model.

  • Potentially improved deployment options with .NET 3.5 SP1, which resolves some issues that made it difficult to put Revit Plugin DLLs in a centralized network location.

As a developer, I also appreciate the ability to take advantage of the newer features of Visual Studio, including the built-in Unit Testing framework and language features like the new "var" keyword - where Visual Studio figures out variable types for you!

Compatibility with Previous Versions

The nature of the changes to the RevitAPI makes it likely that old applications will be broken in 2010, and will require re-compiling and some changes to make them work with 2010.


It is possible, if your ExternalCommand does not make use of any objects or properties that have changed, that the existing DLL will work - but I'd say that any ExternalCommand of any complexity is unlikely to work without changes.



VSTA 2.0



We will talk about VSTA (Visual Studio Tools for Applications - Microsoft's replacement for VBA - Visual Basic for Applications) and Revit separately - but this version of Revit includes the 2.0 version of VSTA.


What's in a Name?


I've historically been curious about the directory that Revit gets installed in, i.e. "C:\Program Files\Revit Architecture 2009". It always seemed like Revit has held onto the "Revit" folder name while the other Autodesk products were all being standardized to be called "Autodesk _____".


So whether they just finally got around to it, or whether there's deeper intrigue - as of Beta 1, the product is now called "Autodesk Revit Architecture 2010", with the folder name to match.



Ok, this post was a little dry and boring - but I felt like these things had to be said up front... I promise it will get better from here :).



What's New in the Revit 2010 API

One of my favorite blog topics of the year is here - the "What's New" posts, describing the new capabilities of the API (application programming interface) for Revit.


In this series of posts, I'll try to lay out both what's new and what it might mean for you.


Since introducing a small .NET API in Revit 8, the API has doubled in size for each release. Obviously, that's not sustainable the bigger the API gets - and while I'm not sure of the "actual" size increase of the 2010 release, I can say that it's impressive in both size and thoughtfulness.


There is so much new, that we will break up the posts as follows


Whew! Even breaking it up into this many pieces, these are still going to be some large topics. I'd better get started.

Monday, January 26, 2009

More inadequacy... and Revit Unit Quirks

It's sad - Jeremy Tammik has blogged more about me than I have this month.
(His latest is an outgrowth of an Autodesk Developer Network question I submitted a couple of weeks ago - about why, in the Revit API, asking for the "SiteAngle" dimesion format data causes an exception - along with a variety of other interest

The short version:
Revit will throw an Exception if:

  • You are running one "vertical" (i.e. Revit Architecture) and you ask for a dimension type which is ONLY in another vertical (i.e. Revit MEP).
  • You ask for one of the four unit types which are un-modifiable (i.e. SiteAngle, SheetLength, etc).

Not very friendly, but at least now you know :).

Thursday, January 22, 2009

The Drought in Posting

I know, I know.... I need to post more...

Part of my excuse for not posting right now is that I'm writing posts that can't be released yet. I always enjoy posting about the new products (Autodesk 2010 products in this case) as soon as it's possible - but I think we're still at least a month and a half away from the "press-embargo" on posting.

I've worked with a variety of early versions - so I'm hopeful I'll have a bunch of stuff queued up to post in the March timeframe.

In the meantime, I'm going to start posting some of my content from the last Autodesk University, for those who couldn't make it.

-Matt

Monday, December 08, 2008

Autodesk University 2008 is over with...

Well - I feel guilty... They gave me an "AU Blogger" ribbon for my badge - and then I didn't manage to Blog during the show. It was an incredibly busy week, including:

- Setup of the Altogether Smarter Challenge stations for Avatech (I'd like to throttle somebody at UPS who thinks that 11/21 to 12/1 constitutes 3-day delivery)...

- The Autodesk Developer Network DevDays conference... for my money, the best day of guidance you can get from Autodesk... Although this year there was a little bit more talk and a little bit less specifics than in previous years.

- We launched our new BIMreview application, which helps check your Revit models for standards and practices, to great feedback from Revit users! The crowd was 3-deep for most of the open exhibit time.

- I did my first solo class - CP315-4: Getting Down to BIM, Advanced Revit API to a crowd of perhaps 60-80 people. That went well (the contents should be posted on the AU site this week... after a little while there, I'll release it more broadly).

All in all, though - an incredibly busy week. And I only got to see about 1/3 of the sessions I had wanted to see.

While I can't share the specifics (much of the ADN stuff is under NDA), my general impressions of what's to come is that:

  • Autodesk continues to invest significantly in AutoCAD, even around 3D and other topics which you might imagine that they would delegate to the vertical products.
  • Autodesk continues to find ways to leverage the Media & Entertainment division software into the Design software side of things.

There's not much more I can say until whenever they free us from the blackout...

Oh yeah - and I think most people know it, but 2010 WILL be a new DWG format, and will break many of the existing applications out there (they plan this - only once every three years).

Monday, November 17, 2008

Jeremy Tammik is a MACHINE!

Recently I mentioned that Jeremy Tammik from Autodesk was starting a blog about developing software with Revit... and he's kept it up at a "blistering" pace - one very solid post every other day just about. It's scary.


It's particularly scary for me, since I'm doing an "Advanced Revit API" class at Autodesk University this year. It's a good thing that Jeremy only started recently - otherwise he would have overrun my class content :) within a few months.


But seriously, though - if you're interested in the Revit API, and how to push it beyond the basics, Jeremy's blog is building a wealth of knowledge.



Thursday, October 23, 2008

Revit 64-bit, and getting your applications there.

Well, we've finally updated and posted a new version of our Revit Utilities which support the new 64-bit versions of Revit 2009.





The good news is - if you're using pure Microsoft.NET - you can probably use your existing Add-in DLLs and everything will work just fine. If, on the other hand, you were making use of outside libraries, Win32 DLLs, or other things like that - then you've got some work ahead of you to get the 64-bit equivalents and figure out how to call the right one.





Why does .NET work so nicely?
Because, by default, when you make a .NET DLL it is compiled into an intermediate language called MSIL - and then it goes through the final step at runtime to become a 32-bit or 64-bit application (32-bit applications need 32-bit DLLs, and 64-bit applications, generally, need 64-bit DLLs). But by default, you build your .NET DLLs to run on "Any CPU":




What definitely needs a change? The Installer :(


So you've got your DLL working - and maybe that was easy... but that's really just the beginning. The installer is where it's a bit more of a pain. Here's why:

1. Registry

If you're reading registry keys to find out the location of Revit (so that you could update the REVIT.INI file) - you've got three new things to look for. Unfortunately, the only way to find where Revit is installed is look at the Uninstall registry keys in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall.

The new keys for 64-bit Revit are:

  • {D2466208-7348-4214-B01E-7BC8729E2BD3} (Revit 2009 Arch 64)
  • {4A98F976-01B5-40E8-A496-AEFD85C3A446} (Revit 2009 MEP 64)
  • {C4B3B3C3-2EE9-48D3-9BF5-4443F7ECF759} (Revit 2009 Struct 64)


2. Another scenario - 32-bit Revit on a 64-bit OS

While this should become uncommon quickly - I've been AMAZED at how many users worldwide are running a 32-bit Revit on a 64-bit OS. Sure, it gives you access to a couple more GIGs of RAM - but oh, the headaches :).

In terms of our own headaches - the biggest one is that Revit's uninstall registry key lies about where Revit is installed (it's actually installed in the C:\Program Files (x86) folder in this case - but that's not what it says).

Also, when you deal with the Registry in general in this scenario, Windows keeps a separate parallel registry for 32-bit applications versus 64-bit applications (check out HKLM\SOFTWARE\WOW6432Node - and find the parallel registry universe).


All in all, if you're doing pure .NET work - it's mostly installer work to get your stuff onto Revit 64. If you're a commercial developer - get moving, because they're jumping to it like you wouldn't believe!

Thursday, September 11, 2008

Welcome two new Autodesk development blogs

I think it's always a good thing when a knowledge-based community gets bigger and the sources more prolific.

So I'd like to point out two new blogs by Autodesk development experts:

I'm a veteran of a good number of training classes and seminars of both of these gentlemen, and they should be a great addition to the CAD development blogging ecosystem.

If you ever get a chance to meet Brian, you have to ask him to show you one of the more simple but mind-bending demos... I spent years looking at Inventor drawings of 3D parts and assemblies - and one day he shows me a simple application which rotates the view of the drawing in 3D (normally you can only pan/zoom in a "2D" drawing). But it turns out that the "2D" drawing was 3D all along - all of a sudden you could see the 3D parts that were "behind" the 2D drawing, titleblock, etc. Very weird and somewhat psychodelic for people in the CAD world, at least (CAD drawings are supposed to be like digital paper, right?).

-Matt

Monday, August 18, 2008

.NET 3.5 SP1 - an obscure gift

JTBWorld pointed out a small but nice enhancement to the latest Service Pack for Microsoft .NET:

The fact that code executing from a network share now has the same permissions as code executing on your local hard drive.

(Begin Venting)
"What? it didn't before? Why?" - obviously you haven't had the pain of trying to make this work. Microsoft's concern was that code executing from a network share could be a virus, worm, etc - something undesirable. So they made it impossible. OK, so it wasn't impossible - they just made it aggravating. To make this work prior to now, you had to go into the world of CASPOL - Code Access Security POLicy, either through your control panel, your company security policies, or the CASPOL.exe command line tool. Fundamentally, you had to make guidelines for when to trust particular .NET assemblies (based on where they were installed, or a signed publisher cerificate, etc).

The joke is - that these restrictions were only for .NET applications. Any hacker who was using a non-.NET language had no such restrictions.

(End Venting)

Anyway - it's good news that it's a changed behavior. This should make it easier for average CAD Managers, IT managers and developers to support a centralized deployment methodology - whether for Revit, AutoCAD, etc.

(Note: Jimmy didn't even have it posted for a day before this caveat came up - you need to add an "acdbmgd.ini" file to force it to not optimize to .NET 3.5 SP1 work with AutoCAD at all).

Saturday, July 19, 2008

The minimum C# to learn to program Revit?

I received a good question the other day from someone who was interested in learning to program Revit. They had done some C programming years ago, and was somewhat overwhelmed by the size of the "Introduction to C#" kind of books (which do tend to be 3+ inches thick).

So I was trying to explain what the core concepts of C# (or any .NET language, for that matter) that they would need in order to get to the point where they would be "dangerous", as they say.

Here are my thoughts:

Object-Oriented Programming (OOP)
Everything in .NET (as well as everything in the Revit API) is built around objects. So you must understand the fundamentals of how to make and use objects.

  • Class definitions
  • Creating new objects
  • Fields and Properties and Methods
  • Object scope/lifecycle
  • The concept of NULL;
  • User Interface (any UI that you do revolves around OOP)

Basic language features
I originally didn't address this... you'll obviously need to learn the basic language features of whatever language you choose. Declarations, IF statements, dealing with Enumerated types, etc...

Enumerators, For loops and Foreach loops
Much of the Revit API revolves around these concepts for looking up elements or other information. Enumerators (or Iterators) is probably the least intuitive of the bunch.

Code Example:

// To go through all of the elements in the model, one way is to do the following:

ElementIterator ei = commandData.Application.ActiveDocument.Elements;

while (ei.MoveNext())
{
Element e = ei.Current as Element;

// now you do something with Element "e".

}

Arrays/Lists

Maybe it's just me, but almost every Revit application I'm involved with makes significant use of Arrays/Lists - so you may as well get comfortable with them. Personally, I'm a fan of what are called "Generic" Lists - which are lists of a specific type of object.

Code Example:

// if we had to go through all the elements, and find the elements that were "Pinned"

// Make our list object
List pinnedElements = new List();

// go through all the elements (NOTE: this way is far slower than some other alternatives - but reasonable for beginners)
ElementIterator ei = commandData.Application.ActiveDocument.Elements;

while (ei.MoveNext())
{
Element e = ei.Current as Element;

if (e.Pinned) pinnedElements.Add( e ); // if it is pinned, add it to the list
}

// now presumably we do something with all those pinned Elements we found...

Object Casting

I'm not sure if they still call it this in the books - but that's how I learned it. This would be used, for example if you had an "Element" from Revit, but you wanted to determine if it was a "Wall" so that you could get the wall-specific information from it.

There are a few mechanisms which support this kind of goal:

Code Example:

// Let's assume that I have "Element e" from one of our routines above, and we want to determine if it's a Wall, so that we can get the Wall width.

//option 1: direct casting

Wall myWall = (Wall)e; // cast "e" into a Wall.

// The down side of this approach? It throws an exception if "e" is not a wall. Which you could catch, but that's time consuming.

// option 2: testing first using the is

if (e is Wall) myWall = (Wall)e;

// this is OK as an approach... better than option 1 at least.

// option 3: using the AS keyword

Wall myWall = e as Wall;

// the benefit here? it casts it if it is the right type. If it's not? then myWall is NULL (which you'll need to test for).

All the methods described above have pros and cons in terms of writing the code and the performance of the application... So they're not meant to be instructive on either, so much as show you some possibilities.

I hope this will be useful to someone...

-Matt

Thursday, July 03, 2008

Speaking at AU on the Revit API

I (finally) got an invitation to speak at Autodesk University this year on the topic of the Revit API.

CP315-4: Getting Down to BIM: Advanced Revit API

I'd been planning to cover topics such as:

  • Essential Tools
  • Understanding Parameters in Depth
  • Filters: New Searching Mechanisms
  • The Challenges of Phases
  • Extracting Geometry
  • Spotlight on: Room Objects

But I've got some time where I can add or remove topics to cover... Are there other areas of interest out there? I'm sure that there will be a ton of other Revit API classes - particularly introductory and VSTA classes... So I'm interested in anything else people would be interested in hearing about.

I'm also interested in adding one topic of my own - an interactive discussion of "What kind of application are you interested in building?" - to try to answer people's questions about whether the application they're thinking about CAN be built using the API... But I'm not sure if this is the right place for that...

Any other suggestions?

-Matt

Monday, June 16, 2008

The Ribbon UI comes to Inventor


I was at the Autodesk Developer Network Manufacturing DevCamp last week, and one of the interesting things I saw was Autodesk's new Ribbon User Interface for Inventor.

While I haven't been wild about the AutoCAD 2009 Ribbon UI, I really like the way that they've implemented this for Inventor. Something about the way they organized it - and the way that you can still use the keyboard shortcuts works nicely. Also the way that you can easily drop into and out of sketch mode more transparently is nice. Perhaps it's because Inventor is fundamentally more structured in terms of contextual menus than AutoCAD (where you can really do any command at any time) - whereas in Inventor you're definitely in Part mode, Assembly mode and drawing mode (etc).

Why should we like Ribbons?
  • Ribbons group tasks together logically
  • Ribbons make obscure functions more "visible" - commands which are buried in menus and rarely see the light of day for regular users will be used more ("Discoverable", I think they call it).

Available Now

Rather than doing like AutoCAD, where it was released in the 2009 version (a suprise for those who weren't involved in the beta program) - the Inventor team is releasing a "Technology Preview" in the middle of the 2009 version.

You can "safely" sample the functionality and provide feedback by downloading the "extended version" of Inventor, which runs happily side-by-side with regular Inventor.

While they've done some work to have 3rd Party add-ins start working automatically (depending on how you've setup your add-in) - I anticipate that there will still be some amount of trouble on that front. The challenge will be - will customers like it so much that they'll use it in production (in which case the add-ins will have to be updated NOW to support production, rather than waiting for Inventor 2010).

In any case - I'm impressed with how well it's implemented. They obviously put a lot of thought into it.

Video:




Download

http://labs.autodesk.com/technologies/inventor2009_ui/

Tuesday, June 03, 2008

The 2009 Revit Utilities are (finally) posted

It was fun, last year, when we posted our free Revit Utilities for Revit 2008. We got nice press, and generally nice comments.

And then came 2009. It's not that it's hard to port applications over to Revit 2009 - it's straightforward, and if you're not doing too much geometry work I'd call it "cake".

But it's every thing else that needs to be taken care of - particularly because we wanted to have this release support both 2008 and 2009 with the new enhancements. So it's updates to installers, and keeping track of multiple DLLs, multiple registry keys, etc. Even that's not so bad.

The worst part is - trying to get something like this published when it's a free product, but you're buried in customer work. Whether it was developers or application engineers for testing or marketing people - it's tough to put down billable work and get it taken care of. Of course, the 5-10 e-mails I got per day requesting the timeline added a little motivation to my guilt.

Just to make things more complicated, we've been working on some other packaged Revit development ideas (which stole the remainder of our free time).

I usually like to have software available within 30 days of the release of the updated CAD version - so we fell short here (apologies). But here they are - published and enhanced for Revit 2008 & 2009 (all flavors).

  • Room Renumber
  • Door Mark Update
  • Change Case
  • Revit Content Browser (Revit City)
  • Earth Connector for Revit
Best Regards,
Matt

P.S. If you've got feedback, please send to devfeedback (at) avatech.com

Wednesday, March 05, 2008

Revit 2009 API: The AddIn Manager

One of the nice additions to the Revit 2009 SDK is the "AddIn Manager" tool.


As background, for those of you who don't know - Revit still uses a 1990s-era REVIT.INI file, with four lines per command to register your Revit external commands, ie:


ECCount=3
...
ECName3=Door Mark Update
ECDescription3=Revit Door Mark Update Utility
ECClassName3=DoorMarkUpdate.Command
ECAssembly3=C:\projects\Avatech\RevitUtilities\DoorMarkUpdate2009.dll


This, combined with the application startup time for Revit, contribute to some occasional pains in getting external commands set up (whether by developers or CAD Managers).

What's New?

The Add In Manager application is itself a Revit External Command, and is accessed (after installation) on the Tools + External Tools menu:





The AddIn Manager shows you what external commands have been registered with Revit, as well as giving you the ability to Load a new command at Runtime (NO MORE EXITING OUT!) and Saving changes to your REVIT.INI file.


Chuck Han had done something like this a year or so ago - but it was mainly for outside of Revit - not something that you could load into Revit after Revit had started. So this is a welcome addition - anything to make the process go more smoothly for Revit Users and administrators!


By the way, the AddIn Manager also handles External Applications:





-Matt

Revit 2009: The Hidden Feature

In previous years, I've really enjoyed ferretting out those "hidden" features or behaviors of Revit in each new release...

This year, I've been poking and prodding - but I've only managed to turn up one thing which I would call a "Hidden Feature".

Revit URL Support
I noticed as you mouse over files in the new Startup Screen, in the bottom left corner you see not the filename - but a URL:







This made me think - does this mean that Revit supports URLs for files now? That might be interesting...

So I tried it - Using "File + Open", I typed in a URL of a Revit File I posted on a website, i.e.:

http://jennmason.com/RevitTest.rvt

And sure enough - Revit automatically downloaded the file and opened it.

Where did it put it locally? It currently is put in your %TEMP% folder (a previous build was putting it in "My Documents" - I'm not sure of my preference).

What does this all mean? I'm not entirely sure, but as models proliferate over the web (or content - my presumption is that you can load a family this way as well) - that Revit being able to open any URL (HTTP, FILE, FTP, etc) - presents some interesting future opportuntities....

(Update: It appears that FTP does not really work... ah well).


Another interesting quirk - I notice that when you mouse-over the "New" button, it gives you a URL of:

file:///X:/NewProject.start

and the Open option gives you file:///X:/OpenProject.start.

I haven't delved into what's going on here... Is this some kind of HTML application that we're actually in? What happens if you actually have an X: drive?

Anyway - this hidden feature seems to inspire as many questions as answers... Have you discovered any "hidden features"? Drop a comment here and let people know!


-Matt