Message 1 of 5
How to Pick a View using ISelectionFilter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Need help creating filter for View
Thanks
Jim
//Comments removed for brevity namespace TESTING.View.Select { public class MySelectView : IExternalCommand { UIDocument m_document; public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { try { m_document = commandData.Application.ActiveUIDocument; Reference viewRef = m_document.Selection.PickObject(ObjectType.Element, new ViewFilter(m_document.Document), "Please pick a View. ESC for cancel."); return Result.Succeeded; } catch (Exceptions.OperationCanceledException) { // Selection Cancelled. For picking face and picking point. return Result.Cancelled; } catch (System.Exception ex) { // If any error, give error information and return failed message = ex.Message; return Result.Failed; } } } public class ViewFilter : ISelectionFilter { Document m_doc = null; public ViewFilter(Document doc) { m_doc = doc; } public bool AllowElement(Element element) { return element is Autodesk.Revit.DB.View; } public bool AllowReference(Reference refer, XYZ point) { return false; } } }