1 Reply Latest reply on Jan 24, 2013 5:27 PM by Artem Taturevych

    Get Block in Multi-sheet Drawing

    Joerg Henke

      I just want to get (delete) the Blocks on the Active Drawing Sheet. With this Code i get all Blocks in Documet. Please help!





      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swSketchMgr As SldWorks.SketchManager

      Dim swSketchBlockDef As SldWorks.SketchBlockDefinition

      Dim swSketchBlockInstance As SldWorks.SketchBlockInstance

      Dim vBlockDefs As Variant

      Dim vBlockInstances As Variant

      Dim swBlockDefSketch As Variant

      Dim swSheet As SldWorks.Sheet

      Dim i As Integer

      Dim j As Integer 

      Sub main() 

      Set swApp = CreateObject("SldWorks.Application")
      Set swModel = swApp.ActiveDoc
      Set swSketchMgr = swModel.SketchManager 

      vBlockDefs = swSketchMgr.GetSketchBlockDefinitions 

      If IsEmpty(vBlockDefs) = False Then 

      For i = 0 To UBound(vBlockDefs) 

      Set swSketchBlockDef = vBlockDefs(i) 

      vBlockInstances = swSketchBlockDef.GetInstances 

      If IsEmpty(vBlockInstances) = False Then 

      For j = 0 To UBound(vBlockInstances) 

      Set swSketchBlockInstance = vBlockInstances(j) 

      Debug.Print swSketchBlockInstance.Name

      Next j 

      End If 

      Next i 

      End If 

      End Sub