Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

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 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:


Thursday, September 20, 2012