I'm currently viewing tutorials for the RevitAPI by udemy, currently on the second video i.e. "Prompt user to select an element, get element info".
When I build the code however, which I just followed from the tutorial, I get the error in the title, like it's saying that it can't find ActiveUIDocument or something.
Code:
namespace promptuser
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("4C3F6AF8-A7AF-4E43-9D90-2DE1A9DB7BA3")]
public partial class ThisDocument
{
public void selectElement()
{
// info about how the revit user interacts with the file
// icludes info about view windows and selection of elements in those windows
// then we get the activeUiDocument use the ff syntax
UIDocument uidoc = this.ActiveUIDocument;
// Database doc = stores info about walls, floors, parameters, etc.
Document doc = uidoc.Document;
// prompt the user to select an object
// Namespace: Autodesk.Revit.UI.Selection
// this would have been the code = uidoc.Selection.PickObject(ObjectType.Element);
// but since this returns a Reference object, store that in a variable
Reference myRef = uidoc.Selection.PickObject(ObjectType.Element);
// get the element itself
Element e = doc.GetElement(myRef);
// display its name, and ID
TaskDialog.Show(e.Name + Environment.NewLine + e.Id);
}
public void SimpleDialog()
{
TaskDialog.Show("This is a title", "Hello Revit WOrld");
}
}
}
I have no idea why this is happening.