MACRO LIBRARY

Get hole wizard feature used by selected hole callout

Free public access. No account or subscription required.

Files

Get hole wizard feature used by selected hole callout

Code

'Preconditions: hole callout is selected in a drawing
'Results: name of hole wizard feature is printed to immediate window, hole wizard _
    definition may then be accessed
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDispDim As SldWorks.DisplayDimension
Dim swAnn As SldWorks.Annotation
Dim vEnts As Variant
Dim swEdge As SldWorks.Edge
Dim swFace1 As SldWorks.Face2
Dim swFace2 As SldWorks.Face2
Dim vFaces As Variant
Dim swSurf As SldWorks.Surface
Dim swFeat As SldWorks.Feature
Dim swHoleWizardFeatData As SldWorks.WizardHoleFeatureData2
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swDispDim = swSelMgr.GetSelectedObject6(1, -1)
    Set swAnn = swDispDim.GetAnnotation
    vEnts = swAnn.GetAttachedEntities3
    Set swEdge = vEnts(0)
    
    'Get the faces adjacent to the used by the hole callout and determine which _
        of those faces is non-planar. This should be a face created by the hole _
        wizard feature. Then we can use IFace2::GetFeature to get the IFeature _
        pointer for that hole wizard feature.
    vFaces = swEdge.GetTwoAdjacentFaces2
    Set swFace1 = vFaces(0)
    Set swFace2 = vFaces(1)
    Set swSurf = swFace1.GetSurface
    If swSurf.IsPlane Then
        Set swFeat = swFace2.GetFeature
    Else
        Set swFeat = swFace1.GetFeature
    End If
    Debug.Print swFeat.Name
    'Set swHoleWizardFeatData = swFeat.GetDefinition
End Sub