Updated SDK, 2012 Products, and Source Code Colourisation

Here are several miscellaneous news items that I would like to pass on before heading off for a week’s vacation:

Updated Revit SDK on Developer Center

An updated version of the Revit SDK has been posted on the
Revit Developer Center.
The differences to the version included with the initial public release of the Revit 2012 product are negligible.
Still, you can always rely on finding the most up-to-date version on the developer centre.
<!–

I installed the update, compared the files, and recompiled SDKSamples2012.sln, ExtensibleStorageManager.sln and RevitLookup.sln. –>

AUGI What’s New in Autodesk 2012 Products

AUGI published their

AUGIWorld March 2011 Issue
with
the topic ‘What’s New in Autodesk 2012 Products’ – a very handy overview of the new product features in many or all of the Autodesk 2012 products.

The Building Coder Source Code Colour Coder

Easter is coming up, so colouring is important … and now that debugging a Revit 2012 add-in requires Visual Studio 2010, and after

migrating The Building Coder samples
,
I obviously need to be able to copy and paste colour coded source code to HTML for the blog posts from that environment as well.

I have been successfully using

CopySourceAsHtml
for
a long time now to copy and paste colour coded source code to the blog posts.

This utility is available for Visual Studio 2003, 2005 and 2008, but not for 2010.

Luckily,

Kean Walmsley recently pointed out
an article on

enabling CopySourceAsHtml in Visual Studio 2010
.
Just like Kean, I was able to follow the steps described and get it working without problems.

By the way, Kean’s article lists a couple of other useful Visual Studio utilities as well, for navigating large source code modules and driving multi-target C++ compiler versions, i.e. running the Visual Studio 2008 version of the C compiler from the 2010 version of the IDE.

CopySourceAsHtml can be set up to encode the HTML colourisation in various ways.
I leave the default settings and do not embed the styles in the code:

Copy source as HTML

Let’s say I use CopySourceAsHtml to copy the following four lines of typical Revit add-in source code:


    public Result Execute(
      ExternalCommandData commandData,
      ref string message,
      ElementSet elements )

That produces the following HTML output with a prepended style definition header:



.cf { font-family: Courier New; font-size: 9pt; color: black; background: white; }
.cl { margin: 0px; }
.cb1 { color: blue; }
.cb2 { color: maroon; }
.cb3 { color: red; }


<style type="text/css">
.cf { font-family: Courier New; font-size: 9pt; color: black; background: white; }
.cl { margin: 0px; }
.cb1 { color: blue; }
.cb2 { color: #2b91af; }
</style>
<div class="cf">
<pre class="cl">    <span class="cb1">public</span> <span class="cb2">Result</span> Execute(</pre>
<pre class="cl">      <span class="cb2">ExternalCommandData</span> commandData,</pre>
<pre class="cl">      <span class="cb1">ref</span> <span class="cb1">string</span> message,</pre>
<pre class="cl">      <span class="cb2">ElementSet</span> elements )</pre>
<pre class="cl"> </pre>
</div>

I then run a little Python script
pycolorize.py
of mine.
It copies its input from the Windows clipboard, modifies it, and pastes it back again.
The modification removes the style definition header, since I have the required style definitions already present in my CSS style sheet:


.blue { color: blue; }
.red { color: red; }
.teal { color: teal; }
.maroon { color: maroon; }
.green { color: green; }
.gray { color: gray; }

It also removes the extraneous div tag, the repetitions of the pre tag, and replaces the cb1, cb2 etc. classes by colour names which correspond to the names of my globally predefined styles, which results in the following much more legible output:


    <span class="blue">public</span> <span class="teal">Result</span> Execute(
      <span class="teal">ExternalCommandData</span> commandData,
      <span class="blue">ref</span> <span class="blue">string</span> message,
      <span class="teal">ElementSet</span> elements )

That is my version of colouring eggs for Easter :-)

Happy Easter!

I celebrated the beautiful full moon with some friends last Monday, which was the
paschal full moon which actually determines the date of
Easter this year.

Anyway, starting tomorrow,

Good Friday
, I will be away for the coming week, taking my Easter holidays, searching for eggs and other happy surprises.

Easter bunny postcard

In the meantime, I wish you a wonderful time and much success with your Revit add-in development efforts and all other important aspects of life, such as love, peace, and happiness for all beings :-)


Comments

3 responses to “Updated SDK, 2012 Products, and Source Code Colourisation”

  1. Trang Avatar
    Trang

    Hi Jeremy,
    I don’t know why all Add-ins are inactivated in 3D View. That is an error or a new property of Revit Architecture 2012?
    liebe Grüße,
    Trang.

  2. Dear Trang,
    There are several possible reasons why external command buttons might be grayed out, e.g.
    – You are in a Revit tool context other than the main selection tool
    – You are in a perspective view (a view generated from a camera)
    – You are in schedule view
    Please check whether the 3D view you are referring to is the Default 3D View, in which case none of the UI widgets should be grayed out.
    If it is a 3D view (perspective view) created using a camera, the UI buttons will be grayed out.
    Cheers and liebe Grüße to you too, Jeremy.

  3. Trang Avatar
    Trang

    Thanks, Jeremy. I got it (^_^)
    Trang

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading