Monday, October 12, 2009

New Visual Studio Theme

I use Visual Studio 2008 Professional in the office, and have recently discovered Scott Hanselman’s blog post on Visual Studio themes.

I’m finding Brad Wilsons Dark Visual Studio theme very easy on my eyes.

If you’re still using the default visual studio theme, check out Scott’s post for some other alternatives, I’m finding it a lot easier on my eyes staring at a black screen all day (and night…) instead of a white one.

Monday, September 28, 2009

Programming for beginners

I’ve seem quite a few instances now of people who are Revit Users that would like to be Revit Programmers as well. I came to Revit development from the other way – I have a background in I.T. and was taught Revit on a need to know basis (this is how you do it in Revit, now go code it, nerd boy!).

If you are someone daunted by programming in general, or perhaps you are someone who did a bit of Autocad customization and doesn’t know much about .NET, a good place to start might be at the MSDN Beginner Developer Learning Centre.

I always recommend that before you try to learn how to program in Revit, you try to understand C#/VB.Net, the .NET framework and software development in general. This site can help you do that, It has a few different tracks (Windows Track is probably best bet for Revit) that you can work through.

Let me know if it helped you out, or if you have any better resources!

Monday, September 7, 2009

Install Certificate button not visible on IE8

A non-programming related blog post for a change. A problem I ran into today in IE8 is that when you manually need to install a certificate (which we need to do for our remote login page) the normal install certificate button was not visible.

A Google brought up this bug report, which suggests you need to run the browser as an administrator for that button to be visible.

Once you right click on IE and run it as an administrator you are then able to install the certificate as per usual!

Thursday, July 23, 2009

Revit API Wish List Survey

Autodesk currently have a survey up that allows Revit API developers to give some feedback on what they would like to see in the API of future Revit releases.

It closes on the 31st of July and is available here: http://www.zoomerang.com/Survey/?p=WEB229BU6PH7J9 

Make sure you head over there and give your feedback. You have no excuse to complain about missing features if you don’t!

Some specific things that I’ve submitted to ADN as a wish list in the past have been:

  • Ability to work with filters (view filters, not the document element filters)
  • Ability to pick a point in the document
  • Ability to change the active view
  • More of the ‘override graphics in view’ menu actions exposed, ie setting elements to be transparent or half tone.
  • Ability to ‘duplicate as dependant’
  • Section mark creation

Now is your chance to tell yours to Autodesk, wether you are in ADN or not!

Wednesday, July 8, 2009

Revit API Search Engine

Hi all,
I had an idea today whilst doing some research for an API program I'm attempting to create.  My normal procedure for this after exhausting my usual resources (SDK, RvtMgdDbg etc), is to search a few of the Revit API blogs out there, then AUGI, Autodesk.com forums etc.

I've found this 'Google custom search' feature that Google has now - you can setup your own search engine to only search certain sites. So I decided to create own with Revit API resources.

http://www.google.com/coop/cse?cx=003379886482190238526:wi7yjrtrkd8 is the full link. I’ve created a slightly easier redirect page at http://RevitAPISearch.RodH.org/

The blogs I’ve got there at the moment are:
http://redbolts.com/blog/
http://revit-programmer.blogspot.com/
http://thebuildingcoder.typepad.com/blog/
http://cadappdev.blogspot.com/
http://roddotnet.blogspot.com

I've added AUGI and Autodesk.com forums in there now, but I'm having trouble restricting the results to just Revit API sections..

http://discussion.autodesk.com/forum...pa?forumID=160
http://forums.augi.com/forumdisplay.php?f=218 are the two links I’ve inserted, and I can choose one of these options:
Include all pages this page links to
Include all partial sites this page links to
Include all sites this page links to

I've experimented with the first 2, and found they still seem to show up results from other forum sections, so I'll have to keep working on that.
My goal here is to try and narrow the results down to the API as much as possible - ie not find info about what buttons to click to insert columns in Revit when you are trying to do it programmatically.

If anyone would like to suggest sites to index please let me know! I’ve started a discussion about AUGI HERE.

Tuesday, July 7, 2009

How to use an app.config file in a DLL plugin (External Command)

This post relates to wider .Net app.config files and linked DLL’s, but more specifically, my instance was relating to the Revit API.

For those that don’t know, an app.config file is a nice, easy way of doing configuration for your applications in .net. You can use the System.Configuration namespace to quickly access an XML config file without needing to do any manual XML reading. Unfortunately, you can only have one app.config file per executable, so if you have DLL’s linked into your application, they cannot have their own app.config files.

Seeing as the Revit API is done by external .Net DLL files which are opened within the Revit environment, this applies to them as well.

At Bornhorst + Ward, we have all of our external commands on a central network share, and each staff members ini is edited (using a tool I’ve written) to point to these external commands. I’d previously tried to use app.config files, and found they weren’t working, it seems they weren’t looking for the correct file in that network directory.

The way around it for me, was to manually locate the app.config file in my code.

   1: /// <summary>
   2: /// Get the configuration for the supplied type
   3: /// </summary>
   4: /// <param name="type">type of class</param>
   5: /// <returns>a configuration</returns>
   6: public static System.Configuration.Configuration GetConfig(Type type)
   7: {
   8:     //workout app.config lokcation
   9:     string dllLocation = type.Assembly.Location + ".config";
  10:  
  11:     if (dllLocation == null)
  12:         throw new Exception("Could not find config file, add .config in DLL location");
  13:  
  14:     //create config
  15:     ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
  16:     fileMap.ExeConfigFilename = dllLocation;
  17:     System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
  18:  
  19:     return config;
  20: }

Seeing as app.config files on DLL’s are named dllName.dll.config this gave me an easy rule for finding the config file. I then used an ExeConfigurationFileMap pointed to that location to generate the Configuration. The ‘type’ parameter, is for me to supply a type (using typeof(ClassName)) to identify the correct dll – as this method for me was written in a separate helper dll which contains some commonly used functions for all of my tools.

Then, to access the properties in that file:

   1: /// <summary>
   2: /// Gets a specific config property
   3: /// </summary>
   4: /// <param name="key">the property to get</param>
   5: /// <param name="type">type of class asking - to get right assembly</param>
   6: /// <returns>value</returns>
   7: public static string GetConfigProperty(string key, Type type)
   8: {
   9:     System.Configuration.Configuration config = GetConfig(type);
  10:     return config.AppSettings.Settings[key].Value;
  11: }

I call that method, supply the typeof(ClassName) of the class calling it, and it gets the configuration from my previous method, and then uses an access method similar to the standard AppSettings class.

Now I can have .configs for all of my revit external commands and access them easily!

Monday, April 27, 2009

Revit: 2010 API Developer Guide

I stumbled across this document today whilst setting up my SDK Samples menus in Revit.

It’s located in the Revit 2010 SDK folder (there’s an extractable on the Revit disc to get this folder) and spotted the ‘Revit 2010 API Developer Guide’.

It’s a 315 page PDF with a whole heap of tutorials, code samples and tips for using the Revit API. It’s pretty much the user manual and seems to be exactly where a new Revit API user should start. This document is exactly what I dreamed of when I started developing with the Revit API a couple of years ago!

The section headings include:

  • Getting Started
  • Add-in Integration
  • Application and Document
  • Elements Essentials
  • Parameters
  • Collections
  • Editing Elements
  • Walls, Floors, Roofs and Openings
  • Family Instances
  • Family Creation
  • Datum and Information Elements
  • Annotation Elements
  • Sketching
  • Views
  • Material
  • Geometry
  • Place and Locations
  • Shared Parameters
  • Transactions
  • Events
  • Revit Architecture
  • Revit Structure
  • Revit MEP

If there isn’t anything there that interests you, you obviously aren’t interested in the Revit API. Props to Autodesk for putting this together!