MACRO LIBRARY

Add callouts to all hole wizard holes

Free public access. No account or subscription required.

Files

Add callouts to all hole wizard holes

Code

Module: mMain

'Demonstrates how to add hole callouts to all hole wizard holes in a drawing view.
    
'Preconditions: A drawing view is selected.
    
'Notes:
'-A hole callout is added for each hole wizard feature, not each hole
'   created by the each hole wizard feature.
'-The hole wizard edge used to create the hole callout is arbitrary.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Option Explicit
    
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swSelMgr As SldWorks.SelectionMgr
    Dim swViewModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View
    Dim vOutline As Variant
    Dim swFeat As SldWorks.Feature
    Dim swEdge As SldWorks.Edge
    Dim vFaces As Variant
    Dim swFace As SldWorks.Face2
    Dim vEdges As Variant
    Dim swEnt As SldWorks.Entity
    
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swDraw = swModel
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    Set swViewModel = swView.ReferencedDocument
    
    vOutline = swView.GetOutline
    
    Set swFeat = swViewModel.FirstFeature
    Do While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "HoleWzd" Then
            vFaces = swFeat.GetFaces
            Set swFace = vFaces(0)
            vEdges = swFace.GetEdges
            Set swEdge = vEdges(0)
            Set swEnt = swEdge
            swView.SelectEntity swEnt, False
            swDraw.AddHoleCallout2 vOutline(0), vOutline(1), 0
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop
End Sub