Etichette

martedì 15 ottobre 2013

Start develop your Revit Add-in - Revit add-in template for visual studio

In this article I would like to show the operations you need to do for developping your own add-in. Following this article you will be able to set your project for each addin you want to develop and you will be able to skip this steps.

In this article I used Visual Studio 2012.

Let's start opening visual studio and clicking on new project in File -> New and following the istructions below you will have a new fastest way to develop your add-ins!

1. The first thing you need to do is to select a template. This is the first time you develop an add-in so you need to create a template valid for all addins you will develop in future. In order to create a template you need to select "Class Library", to type the name below and to select the path clicking on "browse" button.


2. Just clicking on OK button you will be abel to set the visual studio project. You need to set the references to Revit api dll; To do this you need to click on References with right click and to click on "Add Reference..." as you can see in the snap


After that you need to click on "Browse" and to add the references to:
C:\Programfiles\Autodesk\Revit2014\Revitapi.dll
C:\Programfiles\Autodesk\Revit2014\RevitAPIUI.dll
C:\Programfiles\Autodesk\Revit2014\Revitaddinutility.dll

3. Now you are ready to start coding. To complete your addin template you need to call your references in the code. So at the top add these strings:
 using Autodesk.Revit.DB;  
 using Autodesk.Revit.DB.Architecture;  
 using Autodesk.Revit.UI;  
 using Autodesk.Revit.UI.Events;  
 using Autodesk.Revit.UI.Selection;  
 using Autodesk.Revit.ApplicationServices;  
 using Autodesk.Revit.Attributes;  

4. To complete the addin template we need also an addin manifest which will be generated automatically following these steps:

  1. Click on "Project" and click on "Add new item..."
  2. Select XML file, type the name in the textbox and click on "Add"
  3. Now in the solution explorer(the panel on the top right) click on the new xml file added and change the File name in properties to "Revit_app_template.addin"
  4. Follow this instructions to type the code for your addin
  5. In properties set "Copy to output directory" to "copy always"
5. Now you just need to click on file and to Export the template following the instructions.

At these link there is the complete code for the template.

This is just a basic template to start a revit addin. In the next articles I will explain how to set visual studio to test your apps and to build your solution successfully.




Nessun commento:

Posta un commento