Wednesday, November 19, 2014

I was asked recently how to embed and retrieve bmp file into your dll file. I’d like to take credit for figuring it out but I’m sure I originally saw it on Jeremy’s site somewhere.  Here is how I do it:


Add the image as a resource to the project
From the project menu select properties


On the resource tab select add resource


 Browse and find the image.

Once selected it should be listed in the solution explorer under the resources folder



Set the image property to embed
In the solution explorer find the image and right click and go to properties


 Set the build action to embed



Add a reference to  PresentationCore.dll




Once this is done you can use this code to retrieve the image.


Tuesday, April 8, 2014

Crop View To Element

Revit provides tools for isolating elements which is very useful. However often I find that I am also interested in seeing how an element interacts with the elements around it. I have found the best way to do this is to open a 3D view and turn on the views section box. I can then drag around it's edges to show only what I'am interested in. Works pretty well but the manual process is pretty painful.

To create a tool to do this  was fairly simple:

My first crack at the tool works quite well but could be improved by adding a buffer to the bounding box to eliminate the manual manipulation of the section box at the end.



Monday, March 24, 2014

Naming Conventions

Standards I love them! Keeps everything neat, tidy and easy to understand. When it comes to writing code you have a million and one choices to make on how things are done and it is not always easy to decide on a standard way. When it comes to naming though, I follow a few rules:

Class names use PascalCase.




Method names use PascalCase.





Objects use camelCase





Use human readable names. ie. name something using its real name!







Use meaningful descriptive names




These aren't my rules, most come from msdn website here:
http://msdn.microsoft.com/en-us/library/ms229043.aspx



Monday, July 29, 2013

Reinforcement Positioning

Recently I have been modelling some reinforcement in Revit. One annoyance I came across was when 2 bars are close to each other Revit moves one of them to eliminate the clash. Very annoying. I would prefer to be able to place all the reinforcement and then go through the whole model and decide which bars I want to move to eliminate clashes.

After a bit of trial an error I found that if you put the reinforcement into groups you can put the bars wherever you want and revit doesn't try to automatically move them. So I have been grouping bars based upon their shape:





This has the added benefit of being able to tweak a sets location by selecting the group and moving it.



Monday, July 22, 2013

Ribbon Icons

Without pointing fingers, there are some pretty ugly icons out there! I wonder if the people who made these icons realise that in the SDK, Autodesk supply a PDF titled Autodesk Icon Guidelines.




The guidelines go into quite a bit of detail describing things like colours, lighting and shadows. I can imagine if you were a professional icon artist the document would be very useful. I'm obliviously not a professional graphic artist nor do I have the tools of one, but to create good looking icons is easy!

To create my icons I normally take a screen shot of an existing Revit icon then modify it by adding badges or ascents as appropriate. This can all be done using built-in windows tools like snip and  paint.

The end result is icons that have the same look and feel as the Autodesk ones, but more importantly convey to the user the intention of the tool. I like to think without reading the name of the tool, users have an idea of what the tool does.  




You can get your hands on the Guidelines via the SDK download here:

Monday, July 15, 2013

Getting Elements

Quite often when writing code for Revit I need to get all the elements of a particular category. To help me do this I wrote the follow helper method:











So when I need to get elements I call that method. For example to get all the floor elements I use:




Monday, July 8, 2013

Unit Vector

A unit vector is a vector whose length is 1. To convert a vector to a unit vector you simply divide each component of the vector by the vectors length.

For example to find the unit vector of the vector (1, 5, 7):


















Thankfully using the Revit API the calculation is very trivial: