Revit 2010 + .NET3.5 == LINQ

by Guy Robinson 21. March 2009 14:35

You’ll see from the preview information out there that Revit 2010 requires .NET3.5 . There wasn’t anything stopping you from using .NET3.5 with the Revit API in previous releases, but now it’s official there isn’t any excuses not to use one of the coolest aspects of .NET3* .

LINQ or .NET Language Integrated Query is a great way to simplify your code and query the Revit database with a powerful and simple syntax. In conjunction with extension methods there is some real opportunity to make your code look even more beautiful ;-) Here’s a little very simple example (who can spot the extension method)

var mydoors = from door in Document.Elements<FamilyInstance>(BuiltInCategory.OST_Doors)
                             where door.get_Parameter("Width").AsDouble() <= 3.45
                             select new Door(door);

The big question I’m only just starting to look at is performance, particularly compared to parameter filters. LINQ is certainly a power tool even if you don’t use it in conjunction with the Revit API.

Comments are closed

About the Author

A .NET software Developer providing custom applications and commands for architecture firms exclusively working with Autodesk Revit and integration with any associated applications. All from a little place north of Whitianga, New Zealand.

Page List

Disclaimer

I'm self employed so the opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway☺

© Copyright2008

Creative Commons License
Blog content is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

With the following exception. All code snippets, application and libraries are licensed under a a Apache License Version 2.0

Autodesk Revit®

Autodesk: Revit is a product that is wholly owned by Autodesk. Any reference to Revit,Revit API, Revit Architecture, Revit MEP or Revit Structure on this site is made acknowledging this ownership. Refer to Autodesk's own web site and product pages for specific trademark and copyright information. Autodesk represents a great many products and every attempt will be made to respect their ownership whenever one of these other products is mentioned on this site.