2 Replies Latest reply on Jun 9, 2017 7:14 AM by Korbi Anis

    project sketchpoints on face ( in assembly) with a specific direction

    Korbi Anis

      Hello borthers , can somone help me to resolve my problem.I want to project sketchpoints on face ( in assembly) in a specific direction . I tried to use GET PROJECTEDPOINTSON but its does not work.thanks

        • Re: project sketchpoints on face ( in assembly) with a specific direction
          Korbi Anis

          I tried this code but always it return to me a message bow like this  :  "Point is not on the selected face" !!! what the problem


          Dim swApp As SldWorks.SldWorks

          Dim swModel As ModelDoc2

          Dim mathUtils As MathUtility

          Dim boolstatus As Boolean

          Dim swModelDocExt As SldWorks.ModelDocExtension

          Sub main()

          Set swApp = Application.SldWorks

          Set mathUtils = swApp.GetMathUtility()

          Set swModel = swApp.ActiveDoc

            Set swModelDocExt = swModel.Extension

          boolstatus = swModelDocExt.SelectByID2("Point1@Esquisse3D47@P ROUGE-1@Assemblage2radif", "EXTSKETCHPOINT", 8.01721109677942E-02, 0.06475, 0.025, False, 0, Nothing, 0)

          Dim swPt  As SketchPoint

          Set swPt = swModel.SelectionManager.GetSelectedObject6(1, -1)

          Dim Mpt As MathPoint

          Dim swPoint(2) As Double

          Dim swArr As Variant

          swPoint(0) = swPt.X

          swPoint(1) = swPt.Y

          swPoint(2) = swPt.Z

          swArr = swPoint

          Set Mpt = mathUtils.CreatePoint(swArr)



          Dim rayVector As MathVector

          Dim pointdir(2) As Double

          Dim vArr As Variant

          pointdir(0) = 0

          pointdir(1) = 0

          pointdir(2) = 1

          vArr = pointdir

          Set rayVector = mathUtils.CreateVector(vArr)

          boolstatus = swModelDocExt.SelectByID2("", "FACE", 2.68354389024239E-02, 0.126985851602953, 0.167323545036709, False, 0, Nothing, 0) 'Chnage with your Face selection

          Dim face As Face2

          Set face = swModel.SelectionManager.GetSelectedObject6(1, -1)


          Dim surface As surface

          Set surface = face.GetSurface



          Dim InterSectpoint As MathPoint

          Set InterSectpoint = surface.GetProjectedPointOn(Mpt, rayVector)

          If InterSectpoint Is Nothing Then swApp.SendMsgToUser "Point is not on the selected face"


          swModel.ClearSelection2 True

          End Sub