2 Replies Latest reply on Mar 4, 2015 6:04 AM by Manikandan Babu

    how to delete the sketch segment in drawing view through macro

    Manikandan Babu

      Option Explicit

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swdraw As SldWorks.DrawingDoc

      Dim swLayerMgr  As SldWorks.LayerMgr

      Dim swLayer  As SldWorks.Layer

      Dim list As Variant

      Dim count As Integer

      Dim i As Variant

      Dim selmgr As SldWorks.SelectionMgr

      Dim params As Variant

      Dim selfils(20) As Long

      Dim swketch As SldWorks.Sketch

      Dim swketchseg As SldWorks.SketchSegment

      Dim params As Variant

      Dim swSelData As SldWorks.SelectData

      Sub main()

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

      Set swdraw = swModel

      'Set SelMgr = swModel.SelectionManager

      Dim swview As SldWorks.View

      Set swview = swdraw.GetFirstView

      Set swview = swview.GetNextView

      Set swLayerMgr = swdraw.GetLayerManager

      list = swLayerMgr.GetLayerList

      count = swLayerMgr.GetCount

      For i = 0 To UBound(list)

      Set swLayer = swLayerMgr.GetLayer(list(i))

      If list(i) = "flip" Then

      swLayer.Visible = True

      Else

      swLayer.Visible = False

      End If

      Next

      i = 0

      Set swketch = swview.GetSketch

      Dim seg As Variant

      Dim rel As Variant

      seg = swketch.GetSketchSegments

      For i = 0 To UBound(seg)

      Set swketchseg = seg(i)

      swketchseg.Select4 True, swSelData

      swModel.EditDelete                                           'its not working

      swModel.ForceRebuild3 True

      Next

       

      please help me to resolve this

       

      Regards

      Manikandan