Little or Big, BIM is all about the Information.

Revit API : “using” Directive / Statements (C#)

well Hi! It’s 2014. time flies. Im going to say welcome back!

From our pdxRUG presentation today, Marcello asked a great question:

From: MSDN | using Directives: To allow the use of types in a namespace so that you do not have to qualify the use of a type in that namespace:

Blah. that is too syntax heavy for me. Using Directives are shortcuts to give access to specific code references. Think about it like this, I can either call “Autodesk.Revit.DB.View” or i can call “View”…. Which one is easier? Well for me, it’s “View”. And that is the power of a using Directives.

There is an inherent problem with that though. The more dependencies (references to other code) a C# project requires, the higher the chance of (2) or more references having the same Class reference. For example: if you are using “System.Windows.Forms, “View” can either be: “Autodesk.Revit.DB.View” or “System.Windows.Forms.View” and will become an ambiguous reference. See the below tool-tip from Visual Studio.

Below you will see a list of using Directives that I am using in one C# project. I counteract that issue by setting a shorthand name for referencing “System.Windows.Forms” to “WinForm” to remove any ambiguity. Allowing the “View” call to be directed to “Autodesk.Revit.DB.View” like i would like it!

using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB.ExternalService;
using Autodesk.Revit.Utility;
using RvtApplication = Autodesk.Revit.ApplicationServices.Application;
using RvtDocument = Autodesk.Revit.DB.Document;
using Autodesk.Revit.DB.Plumbing;
using WinForm = System.Windows.Forms;

I hope that this clears up the using Directives usage :)

Also, Harry Mattison has posted on BoostYourBim about common using statements.

!!! EDIT: !!!
The second form of “using” is a using Statement.

from MSDN: Provides a convenient syntax that ensures the correct use of IDisposable objects.

Which is wayy to complicated for me to understand. hence my earlier goof up on my initial posting. The using statement allows you to get rid of the data encapsulated within the using statement after it has completed, otherwise stated as “disposing”. If you look at the code block below, I start a “using” statement to create a new transaction and then when the transaction is complete, the transaction “t” is disposed. To do this without the using statement, you would need to manually dispose of the transaction with additional coding.

using (Transaction t = new Transaction("doc","my Transaction"))
//do something

which Harry graciously posted about in the comments below and here is a link to a post he wrote regarding the using blocks:

A little egg on my face, but like i said earlier today, I am learning and I definitely am not a coding mastermind.

Thanks for the Question Marcello!

Room and Room Tag Creation

I have noticed that as a project develops one of the major hurdles is file lag and response time. For instance, adding rooms and room tags can take quite a bit of time. Sometimes adding a new room or room tag to a view the application will cycle through a series of renderings. I find it difficult to believe Revit would take this long to add a tag to a room that already exists.

Continue reading »

AU 2012 Class Highlights

What is this? An Autodesk University blog posts 2 months after the event? Well, a few days ago the AU 2012 Class Recordings went live. We felt it would be good to share the classes we attended that we enjoyed the most! Below are the classes we attended that had some quality take backs for what we do on a daily basis. The links go to the AU Archives so you can watch the videos and download handouts and presentations. Feel free to leave your favorite AU classes in the comments below!

MP1414 Autodesk® Revit® MEP 2013: On Steroids! - David Butts [ @dabutts7 ]

AB2623 Triage for Your Autodesk® Revit® Family – Shawn Zirbes

MP1461 You Did What? AutoCAD® Revit® MEP and AutoCAD® P&ID? Amazing! – David Butts [ @dabutts7 ]

MP3730 Getting to “Zero” with Autodesk® Revit® and Autodesk® Navisworks®

AB3057 Scan to BIM: Point Clouds Reloaded – Kelly Cone (No Recording)

AB3741 Advanced Autodesk® Revit® Modeling Techniques Using Complex Geometry: Walls, Floors, Roofs, and Beams - Marcello Sgambelluri [ @marcellosgamb ]

Navisworks Structure

We are wrapping up a massive programming effort at the office that had 8 separate working Revit models across 8 disciplines and 12 Plant3D models for 2 disciplines. In total, Navisworks is reporting the following statistics:

  • Unique GUIDs: 149,963
  • Total Triangles: 12,758,863

Keep in mind, I said programming models. In most firms, this means mass models, that at best have some walls and key model components. This model acts more like a SD or DD model in many ways but the client required this level of detail to ensure a solid programming effort. Continue reading »

Custom Shape Toposurface Outline in Revit

Have you ever wanted to create a model with a accurate Toposurface but were unhappy with how Revit ‘cleans up’ the edges? Maybe you were trying to do a presentation graphic and wanted to isolate you site. The key is in combining the use of Section Boxes (or Crop Regions) and Building Pads.

(EDIT- See bottom for easier method)

Here is how my Toposurface looked. I purposefully made the Toposurface much larger then it should have been, so I would be able to use a Building Pad & Section Box combo to slice it back. The goal was to create a round outline for the site. There is a model line circle just visible in the image.

Continue reading »

Load more 11 more remaining