1 Reply Latest reply on Jul 2, 2014 9:44 AM by Sushil Chaskar

    Getting 3d intersection curves..

    Sushil Chaskar

      Hii..I am trying to get 3d intersection curves for number of planes.. For this, first I am selecting all faces of model, then getting plane count and then creating 3d intersections for each plane.. But i am able to create only one sketch .. Any thoughts..?


      Option Explicit


      Sub main()


      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swSelMgr As SldWorks.SelectionMgr

      Dim swSelData As SldWorks.SelectData


      Dim swPart As SldWorks.PartDoc


      Dim swBody As SldWorks.Body2


      Dim swFace As SldWorks.Face


      Dim swEnt As SldWorks.Entity


      Dim bRet As Boolean


      Dim vBodies As Variant

      Dim boolstatus As Boolean

      Set swApp = CreateObject("SldWorks.Application")


      Set swModel = swApp.ActiveDoc


      Set swPart = swModel


      Set swSelMgr = swModel.SelectionManager


      Set swSelData = swSelMgr.CreateSelectData


      vBodies = swPart.GetBodies2(swAllBodies, True)


      Set swBody = vBodies(0)


      Set swFace = swBody.GetFirstFace

       

      swModel.ClearSelection2 True

       

      Do While Not swFace Is Nothing


      Set swEnt = swFace

       

      ' Select through Entity


      bRet = swEnt.Select4(True, swSelData): Debug.Assert bRet

       

      Set swFace = swFace.GetNextFace


      Loop

      Dim Count As Integer
      Count = 0
      Dim swfeature As SldWorks.Feature
      Set swfeature = swModel.FirstFeature
      While Not swfeature Is Nothing
      If swfeature.GetTypeName = "RefPlane" Then
      swfeature.Select2 True, 0
      Count = Count + 1
      End If
      Set swfeature = swfeature.GetNextFeature
      Wend

      MsgBox Count
      Dim i As Integer
      For i = 1 To Count - 1
      boolstatus = swModel.Extension.SelectByID2("Plane" & i, "PLANE", 0, 0, 0, False, 0, Nothing, 0)
      swModel.SketchManager.InsertSketch True
      swModel.Sketch3DIntersections
      boolstatus = swModel.Extension.SelectByID2("WEB datum-2", "SURFACEBODY", 0, 0, 0, True, 0, Nothing, 0)
      boolstatus = swModel.Extension.SelectByID2("Imported1", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
      swModel.Sketch3DIntersections
      swModel.ClearSelection2 True
      swModel.Sketch3DIntersections
      swModel.ClearSelection2 True
      swModel.SketchManager.InsertSketch True
      Next i
      End Sub