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