Hide Table of Contents

Get Hole Series Information Example (VB.NET)

This example shows how to get information about a hole series.

' Preconditions:
' 1. Open an assembly that contains a hole series feature.
' 2. Configure holes in the SOLIDWORKS Toolbox.
' Postconditions: Inspect the Immediate window.
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

Dim swDoc As ModelDoc2
Dim SelMgr As SelectionMgr
Dim boolstatus As Boolean
    Dim swFeat As Feature
Dim swFeatData As HoleSeriesFeatureData2
Dim swFace As Face2
Dim swEnt As Entity

Sub main()

        swDoc = swApp.ActiveDoc
        SelMgr = swDoc.SelectionManager
        swFeat = swDoc.FirstFeature

Do While Not swFeat Is Nothing
            Debug.Print(swFeat.GetTypeName & ", " & swFeat.Name)
If swFeat.GetTypeName = "HoleSeries" Then
                swFeatData = swFeat.GetDefinition
"  Standard:", swFeatData.Standard)

Dim i As Integer

                For i = 0 To swFeatData.GetComponentsCount - 1
"  Component " & i)
"    Type:", swFeatData.Type(i))
"    Size:", swFeatData.Size(i))

                Debug.Print("  FastenerMaterial:", swFeatData.Material)

' Bolt and nut information causes an error
                ' if SOLIDWORKS Toolbox is not configured
                Debug.Print("  BoltHeadDiameter:", swFeatData.BoltHeadDiameter)
"  BoltDiameter:", swFeatData.BoltDiameter)
"  NutDiameter:", swFeatData.NutDiameter)
"  FastenerPreload:", swFeatData.Preload)
"  FastenerDefaultUnits:", swFeatData.FastenerDefaultUnits)
"  FastenerTopHoleType:", swFeatData.FastenerTopHoleType)
"  FastenerBottomHoleType:", swFeatData.FastenerBottomHoleType)
"  FastenerHoleCount:", swFeatData.FastenerHoleCount)

' End face
                swFeatData.AccessSelections(swDoc, Nothing)
                swFace = swFeatData.EndFace
                swEnt = swFace

If Not swEnt Is Nothing Then
                    boolstatus = swEnt.Select4(False, Nothing)
" Face selection = " & boolstatus)
End If

                ' Sketch points
                Dim ncount As Integer
                ncount = swFeatData.GetSketchPointsCount
" Sketch Point Count = " & ncount)

Dim vPtArr As Object
                vPtArr = swFeatData.GetSketchPoints

Dim swSketchPoint As SketchPoint

For i = 0 To i = ncount - 1
                    swSketchPoint = vPtArr(i)
False, Nothing)

                ' Components
                ncount = swFeatData.GetComponentsCount
"  ComponentsCount Count = " & ncount)
                vPtArr = swFeatData.GetComponents
Dim swComp As Component

For i = 0 To i = ncount - 1
                    swComp = vPtArr(i)
If Not swComp Is Nothing Then
                        Debug.Print("  " & swComp.Name2 & " --> " & swComp.GetPathName)
                        Debug.Print("  Could not get component.")
End If


End If

            swFeat = swFeat.GetNextFeature


    End Sub

Public swApp As SldWorks

End Class


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Get Hole Series Information Example (VB.NET)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.