AnsweredAssumed Answered

Find largest surface on named plane?

Question asked by Todd Bennett on Apr 2, 2020
Latest reply on Apr 2, 2020 by Matthew Cempa

Is there a way to find the total surface area on a plane?  I got this from (below) - don't know where.  It finds the largest surface of a part.  Of course, it isn't necessarily planar surface.  Is there a way to specifically look at surfaces that are co-planar with a named plane and add the results?

 

I have a plane named "MyPlane".

I know there are any number co-planar surfaces (always has at least one).

Is there a way to only find the largest surface on this plane?

 

 

 

Sub main()
'finds the face with the most surface area
'the face may not be planar

 

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swPart As SldWorks.PartDoc
    Dim vBodies As Variant
    Dim swBody As SldWorks.Body2
    Dim swFace As SldWorks.Face2
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swPart = swModel
    
    vBodies = swPart.GetBodies2(swBodyType_e.swSolidBody, False)
    
    Set swBody = vBodies(0)
    Set swFace = swBody.GetFirstFace
    
    Dim Area As Double
    
    While Not swFace Is Nothing
        If swFace.GetArea > Area Then
            swFace.Select2 False, -1
            Area = swFace.GetArea
        End If
        Set swFace = swFace.GetNextFace
    Wend
    
End Sub

Outcomes