API Project Browser aka Solution Explorer
What does the Solution Explorer contain? First off, you can see it’s sort of the same treelike sorting that Revit uses. On top, you start with the file itself, being Solution ‘ClassLibrary1’. This contains three parts:
The Properties part contains well, the project properties. Double click on the AssemblyInfo.cs file and this will pop up:
There are a few things you should know about the format off coding and then this whole thing will start to make sense.
First off, the dark blue text is an executive command. Do this, look there, etc. So this code starts with defining which parts of the .NET building blocks are used. Like Revit uses classes (Door, Window, Wall, etc) the API also uses classes. Like the Revit classes these API classes have different behavior and usability. So, when you start to write a piece of code, you´ll need to specify in which classes you want to be digging around. No worries though, this can be edited throughout the whole process of writing the software.
The light blue text is a sort of parameter. What needs to be handled? In this case the executive command is to build an assembly with a number of parameters like Title, Description, etc.
The “red text” is just that: a text. In these case the parameters are text parameters. The infilling data has to be placed in between double quotation stabbings (and turns red if you do so)
Next the //green text//: this is actually a way to place notes within the code without it being used in the software that you are writing. So you use this to add notes, descriptions, clarifications and sometimes random mumbling when it all becomes too much to handle.
Then comes a few lines of codes which fill in the actual information about the Assembly (piece of software) you are making. It’s formatted like this:
[Executive command: Parameter("Text description")]
Notice that an executive command is always in between , and a parameter is also in between ().
First line of this part defines that the piece of software will be named ClassLibrary1
Second line leaves a blank description for it, etc.
You can fill this out at your own wishes.
I´ve filled out all text parameters and added some remarks. Then Save All
Working in VS means you are working with different files. All *.cs files are parts of the project. So if you want to save your project, you don’t use Save but use Save All (on the right side of the Save button). When saving all for the first time you will get a popup asking where the project should be saved. If you leave the checkbox “Create directory for solution” checked it will automatically create a Windows folder in which all parts are saved. After saving you will notice that the naming of the file on the right has changed.
Also note that every change you make in the coding screen will leave a yellow marking in front of the text line. After saving, these markings will turn green.
The References define the .NET containers that you want to use. In this case, some System containers. Don’t quite know what they do, but since they were in the Template I’ll leave them be.
BUT, since we’re trying to create a Revit plugin, you will need to reference to the Revit program too. To do this, you’ll need to load two Revit DLL’s: RevitAPI.dll and RevitAPIUI.dll. This will actually tell the Addin that it’s supposed to work with Revit.
To do this, right-click on References and select Add Reference. In the Popup screen go to Browse and find these two files in the Revit program folder: RevitAPI.dll and RevitAPIUI.dll.
Add RevitAPI references