Hi all!
I have just created my first Add-in for Revit which will help me to do a simple selection.
I know it sounds weird, but using basic Revit selection it is not possible (as far as I know) to select insulation of the ducts or pipes. Using my add-in, I can simply select pipe with its insulation and filter it out afterwards.
The problem I need to solve is a pop-up window which appears when I run my add-in and hit ESC right away without making any elements selection.
What is the best way to prevent of showing that window? All I want is Revit to terminate my add-in in the background without any pop-up windows as per my attachment below.
Thanks.
Code that I have atm:
namespace RevitAddin
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
try
{
// Use the rectangle picking tool to identify model elements to select.
IList<Element> pickedElements = uidoc.Selection.PickElementsByRectangle("Select by rectangle");
if (pickedElements.Count > 0)
{
// Collect Ids of all picked elements
IList<ElementId> idsToSelect = new List<ElementId>(pickedElements.Count);
foreach (Element element in pickedElements)
{
idsToSelect.Add(element.Id);
}
// Update the current selection
uidoc.Selection.SetElementIds(idsToSelect);
}
return Result.Succeeded;
}
catch (Exception e)
{
message = e.Message;
return Result.Failed;
}
}
}
}