Start up an F# Solution for Revit Plug-In

Setting up a convenient coding environment is the first step towards efficiency. By using Microsoft Visual Studio, we can easily set up a solution with project(s).

When it comes to selection of the type of coding language, we use Visual F# and since our aim is to compile a dynamic-link library (.dll) file, we select “Library”.

After click OK, Visual Studio (VS) will create the necessary element in the folder that we gave for location, then the editing interface will show up and we are all set for coding!

Using the last posted command as an example, for starting an external command, we need to assign an attribute to the type/class “ASimpleMessage” as indecated in line 4 and for replying a message by using class “TaskDialog” and overload its “Show” method, we have to firstly reference the Attributes and UI namespace (as in line 2 and 3) from the assemblies – RevitAPI.dll and RevitAPIUI.dll, by right-click on the tree view member “References” in the Solution Explorer and at the drop-down select “Add Reference”.

After adding the references by pointing to their locations in the Revit program folder, the references are ready for use and listed inside the references list. However, a convenient way for not forgetting to open the needed namespaces is when the auto-correction in VS shows the red curly lines under the certain code part, hoovering your cursor and click on its correcting suggestion and VS will add the necessary reference in your code for you.

Where there are no more red curly marks, we can try to build our library. Building command is located in the toolbar under “Build > Build + project name“. By default, the built .dll file will be found in your project debug folder. Add this path to your .dll file in your add-in file for your assembly path, then you’ve got the external command ready for utilizing in Revit!

Stay tuned!

Published by

Ching-Hua Chen / 陳景華

The logic behind coding structures will be unveiled during step by step practices. A strong background from computer science is not what I have. I’m just an enthusiast of programming, especially in fields of geometry and architecture. Currently I work for an office in Vienna on a BIM project and I write codes in F# and Python, if needed, for the project, but mostly for my own interest.

2 thoughts on “Start up an F# Solution for Revit Plug-In”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.