AnsweredAssumed Answered

How to retrieve 4 corner root point of the plane or surface?

Question asked by Eng Woei Lim on Dec 14, 2016

I using this code to retrieve the root point of a surface. I need the XYZ coordinates to do some translation at later stage. However, the problem I am facing is, on different part file (but same shape and geometry,just drawn by different user), the root point is reported on different corner, sometime bottom left corner, sometime top left corner, anyway to fix it or retrieve all the 4 corner?

 

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swFace                  As SldWorks.face2

    Dim swSurf                  As SldWorks.surface

    Dim vPlane                  As Variant

    Dim i                       As Long

    Dim bRet                    As Boolean

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swFace = swSelMgr.GetSelectedObject5(1)

    Set swSurf = swFace.GetSurface

   

    If swSurf.IsPlane Then

        vPlane = swSurf.PlaneParams

       

        Debug.Print "File = " & swModel.GetPathName

        Debug.Print "  normal         = (" & vPlane(0) & ", " & vPlane(1) & ", " & vPlane(2) & ")"

        Debug.Print "  root           = (" & vPlane(3) * 1000# & ", " & vPlane(4) * 1000# & ", " & vPlane(5) * 1000# & ") mm"

    End If

End Sub

Outcomes