AnsweredAssumed Answered


Question asked by Mohammed Gh on Jul 21, 2015
Latest reply on Sep 9, 2015 by Mohammed Gh



I am trying to get the result (x,y, and z coordinate) of vertical projection of two points on a knitted surface.
RayIntersections and GetRayIntersectionsPoints look promising but there no good documentation. Even on the solidworks api help website.



Attached the file I am working on and below is the script.

Could you please look at the script and tell me what is wrong with it and/or if you have a better aproche or a good documentation about how to get the coordinate of the vertical projection of the two points on the surface.






    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2

    Dim swSelMgr As SldWorks.SelectionMgr

    Dim swBody(0) As SldWorks.Body2

    Dim boolstatus  As Boolean


Sub main()

        Set swApp = Application.SldWorks

        Set swModel = swApp.ActiveDoc

        Set swSelMgr = swModel.SelectionManager

        boolstatus = swModel.Extension.SelectByID2("surface", "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)


        Set swBody(0) = swSelMgr.GetSelectedObject6(1, -1)  ''

        Dim PointsArray(5) As Double


        dPtArr(0) = -1.14329

        dPtArr(1) = 0.11616

        dPtArr(2) = 0.0017

         dPtArr(3) = -37.9361194

         dPtArr(4) = -4.57

         dPtArr(5) = 0.54


         Dim dVecArr(2) As Double


        dVecArr(0) = 0

        dVecArr(1) = -1

        dVecArr(2) = 0


        Const hitRadius As Double = 0.0000095


        Const offset As Double = 0.0000001


        Dim nNoOfInterestions As Integer


        Debug.Print swModel.RayIntersections(swBody, dPtArr, dVecArr, swRayPtsOptsTOPOLS, hitRadius, offset)




        Dim vPts As Variant


        vPts = swModel.GetRayIntersectionsPoints




    End Sub