top of page

Getting started with Revit #API Programming

  1. Included in Revit #SDK is CHM help file. It is very important for offline reference when coding. or you can also visit Revit API Docs

  2. Getting Started with first code:


Go to Manage Tab and under Macros, Click on icon highlighted as above.



Under Macro Manager, create new Module and under Module, Create a Macro. Click on the macro name and click on Edit to open #Sharp Develop


Add the following at the start of the code under ThisApplication.cs

sing System;

using Autodesk.Revit.DB.Structure;

using Autodesk.Revit.UI;

using Autodesk.Revit.DB;

using Autodesk.Revit.UI.Selection;

using System.Collections.Generic;

using System.Linq;


Add the following code under "ModuleName" namespace to make a simple dialog box app in Revit:

publicvoidSimpleDialog()

{

UIDocument uidoc=this.ActiveUIDocument; //Represent currently open project in Revit and provides access to UI functions like Selection

Document doc=uidoc.Document; //Represent access to database,Contain elements,views, objects, inside Document f

Reference my=uidoc.Selection.PickObject(ObjectType.Element); //Reference is to reference geometric elements throuugh UIDocument


Element e=doc.GetElement(my); //Element represents revit elements like Wall,Floor and Dimensions & GetElement gets element through reference "my", which go element through uidoc

string a="None";

if(e.DesignOption!=null)

a=e.DesignOption.Name;

TaskDialog.Show("Info about Selected Element",e.Name+"\n"+a); //TaskDialog method is used for display dialog box



}


save the macro and Click on Build Solution under Build Menu to build the app. Go back to Macro Manager in Revit, Select Macro name and click on Run to execute.


To learn more of Revit API, contact us on sohail@srdabimtech.com or call us on +91 83690 91817




63 views0 comments
bottom of page