how pick face like pick to host

how pick face like pick to host

AndrewButenko
Advocate Advocate
826 Views
1 Reply
Message 1 of 2

how pick face like pick to host

AndrewButenko
Advocate
Advocate

Hello! 

How pick only side face of wall by revit api? 

I use code:

 

 

Public Sub SelectPlanarFaces(document As Autodesk.Revit.DB.Document)
    Dim uidoc As New UIDocument(document)
    Dim selFilter As ISelectionFilter = New PlanarFacesSelectionFilter(document)
    Dim faces As IList(Of Reference) = uidoc.Selection.PickObjects(ObjectType.Face, selFilter, "Select multiple planar faces")
End Sub

Public Class PlanarFacesSelectionFilter
    Implements ISelectionFilter
    Private doc As Document = Nothing
    Public Sub New(document As Document)
        doc = document
    End Sub

    Public Function AllowElement(element As Element) As Boolean Implements ISelectionFilter.AllowElement
        Return True
    End Function

    Public Function AllowReference(refer As Reference, point As XYZ) As Boolean Implements ISelectionFilter.AllowReference
        If TypeOf doc.GetElement(refer).GetGeometryObjectFromReference(refer) Is PlanarFace Then
            ' Only return true for planar faces. Non-planar faces will not be selectable
            Return True
        End If
        Return False
    End Function
End Class

What condition I must insert to function AllowReference for pick only side face?

 

0 Likes
Accepted solutions (1)
827 Views
1 Reply
Reply (1)
Message 2 of 2

aignatovich
Advisor
Advisor
Accepted solution

Hi!

 

Try this:

 

Firstly, check, if the element is wall in AllowElement method of your selection filter.

 

Secondly, compare your references (stable representations) with any of references, that are returned by HostObjectUtils.GetSideFaces method