DevLab Munich

I arrived in Gothenburg last night.

Today I participate in my last DevDay conference for this year.

Adam and Jim are continuing to Moscow, where they will be supported by Vladimir and the rest of the team there.

Last week we conducted DevDay conferences in Paris, Milano and Farnborough, ending with a two-day stay in Munich to hold a DevDay conference followed by a DevLab workshop.

A DevLab is an open event where developers roll up bringing their current work and issues and continue developing side by side with one or more ADN DevTech engineers, in this case your humble correspondent.

This time, we organised it as a round table with everybody contributing and sharing ideas on everything together instead of holding one-on-one sessions with people waiting their turn.

Here is an overview of the participants and the numerous issues we discussed:

Overview and Participants


Somewhat miraculously, we managed to discuss all of these topics and provide some ideas on resolving each.

We even had some time left over at the end for a leisurely chat to round off the hectic week.


At the DevDay conference, we were told about banned.h. What is that?

Banned.h is a new C header file introduced in Visual Studio 2012 that automatically warns a developer about unsafe C and C++ function usage. It is a sanitizing resource that lists all banned APIs and helps you locate them in your code. It uses pre-processor #define pragmas to ensure that the compiler produces notifications about unsafe function calls. Replacements for the unsafe functions have been around for a long time, but calls to the unsafe functions may still be around, e.g. from age-old code.

Hello World for an AppStore App

Where can I find a minimal introduction to creating an Autodesk Exchange AppStore application, e.g. a simple 'Hello, world' example?

Look at the Exchange App videos on YouTube.

How to use Python with Revit

Look at the article on intimate Revit database exploration with the Python shell, the RevitPythonShell home page, other articles on it, and also the similar RevitRubyShell.

How to Make a Dockable Tool Palette

Here is a list of several dockable tool palette samples.

Unit Testing

Unit testing is important and can lead to a completely new approach to developing and programming.

Two serious unit testing frameworks for Revit add-ins have now been presented, both of them based on NUnit:

Here is a collection of The Building Coder unit testing articles.

Overview of the GitHub Examples

Could you please provide an overview of the examples that you currently provide on GitHub?

Yes, sure; here they are:

Loading the Building Coder Samples

How do I load The Building Coder samples?

They are loaded by the RvtSamples SDK external application. You first need to set up RvtSamples as usual to load all the standard Revit SDK samples. When that is working, you add the include file BcSamples.txt at the end of RvtSamples.txt as described in loading The Building Coder samples way back in the year 2008.

Worksharing and Add-ins

This is a really important topic.

If your users are using worksharing and worksets, you absolutely must look at Scott Conover's Autodesk University class on Revit add-ins that cooperate with worksharing.

Avoid using ProjectInfo to store data for your add-in, since that element is required by all users!

Place extensible storage on private DataStorage elements to minimize conflicts.

Understand best practice for worksharing and worksets from the product point of view, and ensure your add-in interferes as little as possible!

Dynamic Update of Elements that Mutually Influence each Other

How can I implement relationships where one element influences another in the Revit BIM?

You can use a combination of extensible storage and DMU. Store the element ids of the relationship in estorage. Example: distributing trees along a model curve across a terrain model. Extensible storage stores the required rules and other parameters. The model curve is the parent; each element stores its parent in estorage. On modification, destroy the old instances and create new ones. Store the collection of child element ids in parent estorage. In the add-in options, you can control DMU activity and toggle it on and off to reduce the performance impact. DMU does not allow element creation. Sometimes the DMU updater Execute method needs to subscribe to another follow-up event, e.g. Idling or something, since it cannot commit all required changes in one single transaction.

Availability of a Solid Modeller Inside a Revit Project

How can I define an arbitrary solid shape out of the blue in the project, e.g. a box with a spherical hole?

In Revit 2014, you have to create a family and insert an instance. Look at the FreeFormElement SDK sample. The solid to subtract can be an arbitrary geometry instance. Pump them into the BooleanOperationsUtils class and e.g. its ExecuteBooleanOperation method. The resulting volume is immediately accessible e.g. by querying the toSubtract.Volume property. There are other possibilities as well, e.g. the instance void cut utils.

Intersection Between Elements

On one hand, all the aspects mentioned above regarding Boolean operations between elements apply.

On the other hand, you can also use the pure geometry memory-only BooleanOperationsUtils class ExecuteBooleanOperation method.

Multi-language Shared Parameters

We recently discussed an interesting workaround showing how to implement multi-language shared parameter.

To specify the parameter group, include the appropriate BuiltInParameterGroup PG_ enum value in the call to create the parameter definition.

Point Clouds

How can I get more than a million points?

The point cloud itself was expanded from 1 to 20 million points in Revit 2014, but the API is still limited to 1 million.

For the point cloud engines, how can we retrieve the settings, e.g. the view options defining whether scans should be displayed or not?

Access to CSV Files and Internal Data Defining Parameter Value Lookup Tables

In Revit 2014, the CSV file family parameter value lookup tables can be moved from the project space to the family environment and embedded into the family definition. Load it into the family and send the family to a customer in one single file.

How can we programmatically extract this CSV information back out of the family definition?

In family parameters, you can use the lookup function. E.g., look at Pipe fitting > Edit family > Types and properties:

   Lookup Table Name, "FOD",
   Nominal Diameter + 3.2 mm,
   Nominal Diameter)

This functionality is usable in any kind of family. It specifies all valid parameter combinations in individual rows.

Family instance > Symbol > Parameters > Conduit Size Lookup > Value filename.csv.

How to access this data from the API?

Look at the value of the 'Lookup Table Name' parameter in the family types and parameters. This name may vary for different families, though.

When the lookup table is loaded into the family, it may differ from the content of the external CSV file.

Where is it if it has been loaded into the family? You import the whole file content into the family. Look at the FamilySizeTableManager documentation in the Revit API help file RevitAPI.chm.

Analysis Visualisation Framework

The Building Coder defines a whole category for the Analysis Visualisation Framework AVF.

The Revit Webcam demonstrates grabbing real-time webcam images and using AVF to display a grey scale animated version on the surface of a building element. Note that it is a pretty old sample with an out-dated implementation of the handling of the Idling event. The more recent RoomEditorApp provides a better example of that aspect, and better still how to replace Idling by an external event.

Edit a Floor

We looked at how to edit a floor profile by creating a new floor based on the existing floor's boundary edges.

How can we access the existing sketch elements?

You can use the temporary transaction hack to delete it and retrieve the sketch elements, then edit those as described by Joe Ye in changing the boundary of floors and slabs.

There is obviously the problem of losing hosted elements.

Another discussion on creating a nonrectangular slab explains the SlabShapeEditor and the SlabShapeEditing SDK sample. It emulates the built-in command to pick supports, accessible by drawing a floor with no slope and picking Shape Editing > Modify Subelements > Add Point > Add Spline > Pick Supports. What we would need in this case, however, is the Edit Boundary command.

Preview Control

Can I add my own navigation options to the preview control?

The only input to the preview control is via the constructor.

You could try to some widgets of your own on top of it via the Windows or .NET API, but how to get them to affect the view is another question.

One input to the constructor is the Revit view, which links to a real view element in the Revit model. You might be able to change its settings via the Revit API, and that might update the preview control also. There is some kind of link between the view in the preview and the original Revit view. One may update the other, and vice versa, it seems.

Access to a Sketch Line in an Extrusion in a Family

How can I determine the area of glass in a window in a family?

If rectangular, take width by height, but for the general case...

For the general case, the glass is represented by its own extrusion or solid. Query that solid for its faces, identify the face in the correct plane, e.g. the front reference plane, and ask it for its area.

Load and Prompt for Placement of Group

The 'My First Revit Add-in' tutorial example shows how to place groups of elements: Lesson 6: Working with Room Geometry. The PlaceGroup method inserts a group. If your group is defined in a separate RVT file, you can open that in the background and use the copy and paste API to bring in its elements into the current project, then group them if needed and place the group using the PlaceGroup method.

Connect Pipe or Conduit to Junction Box

In the UI you can grab a junction box and add connectors to it, nota bene in the project, not the family environment. Produce reproducible sample and we'll take a look.

How to Determine the Area and Volume of a Hole Generated by a Window

Several different approaches, e.g.

Programmatically Generate User Input to Revit Commands

How can I programmatically provide input to Revit built-in commands?

The Revit journal file record and stores all user input. You can play back a Revit journal file, but only in its entirety. Another approach to record and playback user input is to use the Windows journal. You can subscribe to the Windows journaling mechanism, record all events that are of interest to you, and play them back. If I want to input the start and end point of a wall, e.g. I may need to convert between Revit and Windows coordinate systems. This is demonstrated by the customised tooltip add-in. The Revit API UIView class provides the coordinates of the view corners in both Revit and Windows coordinate systems, and that enables you to define a transform between the two.

That was that. A successful day!

Now I have to go off and give my presentations here in Gothenburg. Wish me luck!