Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SW Macro to list hole wizard features and measures the diamter of modeled hole

Status
Not open for further replies.

33MRM33

Mechanical
Sep 13, 2024
2
Hi all, new here.

Familiar with Macros, mainly recording them and tweaking them slightly.

I'm looking for a design checking macro in a part file that will list the names of hole wizard features and list their modeled diameter. We typically model the thru hole of a tapped hole as the major diamter, so an M6 will be a 6mm ID hole. I am looking for an easy macro that would list the values so I can quickly go through the list and verify the holes are modeled correctly. Or even somehow flag when the major diamter option in the Hole Wizard has not been selected.

Working currently in 2021 soon to be 2024

Thanks all!
 
Replies continue below

Recommended for you

I don't know if can be done.
I would not model special threaded holes with Hole Wizard. I don't understand the extra effort.
Use the standard callout, let the CNC machinist use the data for the proper tap.

Chris, CSWP
SolidWorks
ctophers home
 
ctopher,

sorry if I was unclear, its not a special modeled threaded hole or any other feature, I am using the hole wizard with generic tapped hole callouts (ANSI Metric) and this would just be for the designers to check their work since sometimes we have a dozen or more tapped holes in a part. The typical process in checking would be to go through the feature tree, select a tapped hole, find in in the model, go measure it, and verify against the hole callout size (M6 tapped hole in feature tree measures 6mm ID).

This is an attempt to speed up the checking process, also a grander scheme to keep adding to a "geometry checker" macro that is tailored to our typical checks.

Our drawings will callout the typical hole callout, letting the machinist do their thing.

Hopefully this helps clear things up
 
Hi, 33MRM33:

It can be done. But I don't see any value in doing so. It is far better to evaluate holes graphically using features in the design tree.

Personally, I don't think it is a good idea to model M6 thread holes as dia. 6mm hole because it is fake. If I were you, I would model true geometries using Solidworks hole features.

If you deal with a large assembly, you can run an interference analysis that will tell if and how bad the interferences are with Fastners.

Best regards,

Alex
 
Try following codes. Add more hole cases as needed.


Code:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim HoleFeatData As SldWorks.WizardHoleFeatureData2
Sub Main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

swModel.ClearSelection2 True


Set swFeat = swModel.FirstFeature
    
    Do While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "HoleWzd" Then
            Set HoleFeatData = swFeat.GetDefinition
                                 
            Select Case HoleFeatData.Type
            
            Case "22" 'swHoleBlind
            Debug.Print HoleFeatData.HoleDiameter * 1000# & " mm"
            
            Case "25" 'swHoleThru
            Debug.Print HoleFeatData.ThruHoleDiameter * 1000# & " mm"
            
            Case "52" 'swTapThruThreadThru
            Debug.Print HoleFeatData.TapDrillDiameter * 1000# & " mm"
            
            End Select
            
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop

End Sub

Deepak Gupta
SOLIDWORKS Champion and Expert
SW 2024 SP2.0, 2023 SP5.0, 2022 SP5.0, 2021 SP5.1 and 2020 SP5.0
Boxer's SOLIDWORKS Blog


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor