Hide Table of Contents

Get Hole Series Information Example (VBA)

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

 

'****************************************************************

'

' Preconditions: Open assembly that contains hole series feature

'

' Postconditions: None.

'

'****************************************************************

Option Explicit

 

Dim swApp As SldWorks.SldWorks ' Object

Dim swDoc As SldWorks.ModelDoc2 ' Object

Dim SelMgr As SldWorks.SelectionMgr ' Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim swFeat As SldWorks.Feature

Dim swFeatData As SldWorks.HoleSeriesFeatureData

Dim swFace As SldWorks.Face2

Dim swEnt As SldWorks.Entity

 

Sub main()

 

    On Error GoTo ErrorHandler

    

    Set swApp = Application.SldWorks

    Set swDoc = swApp.ActiveDoc

    Set SelMgr = swDoc.SelectionManager

    Set swFeat = swDoc.FirstFeature

    Do While Not swFeat Is Nothing

        Debug.Print swFeat.GetTypeName, swFeat.Name

          If swFeat.GetTypeName = "HoleSeries" Then

               Set swFeatData = swFeat.GetDefinition

                

               Debug.Print "Standard:", swFeatData.Standard

               swFeatData.Standard = 2

               Debug.Print "Standard:", swFeatData.Standard

     

               Dim i As Long

               For i = 0 To swFeatData.GetComponentsCount - 1

                Debug.Print "Component " & i

                Debug.Print "  Type:", swFeatData.Type(i)

                Debug.Print "  Size:", swFeatData.Size(i)

               Next

               

               Debug.Print "FastenerMaterial:", swFeatData.Material

               

               ' Bolt and nut information causes an error

               ' if SolidWorks Toolbox is not configured

               Debug.Print "BoltHeadDiameter:", swFeatData.BoltHeadDiameter

               Debug.Print "BoltDiameter:", swFeatData.BoltDiameter

               Debug.Print "NutDiameter:", swFeatData.NutDiameter

                

               Debug.Print "FastenerPreload:", swFeatData.Preload

     

               Debug.Print "FastenerDefaultUnits:", swFeatData.FastenerDefaultUnits

               Debug.Print "FastenerTopHoleType:", swFeatData.FastenerTopHoleType

               Debug.Print "FastenerBottomHoleType:", swFeatData.FastenerBottomHoleType

               Debug.Print "FastenerHoleCount:", swFeatData.FastenerHoleCount

               

                ' End face

                swFeatData.AccessSelections swDoc, Nothing

                Set swFace = swFeatData.EndFace

                Set swEnt = swFace

                

                If Not swEnt Is Nothing Then

                    boolstatus = swEnt.Select4(False, Nothing): Debug.Assert boolstatus

                    Debug.Print " Face selection = " & boolstatus

                    swFeatData.EndFace = swFace

                End If

                

                ' Sketch points

                Dim ncount As Long

                ncount = swFeatData.GetSketchPointsCount

                Debug.Print " Sketch Point Count = " & ncount

                

                Dim vPtArr As Variant

                vPtArr = swFeatData.GetSketchPoints

                Dim pt As Object

                Dim swSketchPoint As SldWorks.SketchPoint

                For Each pt In vPtArr

                   Set swSketchPoint = pt

                  pt.Select4 False, Nothing

                Next

                

               ' Components

               ncount = swFeatData.GetComponentsCount

               Debug.Print "ComponentsCount Count = " & ncount

               vPtArr = swFeatData.GetComponents

               Dim swComp As Object

               For Each pt In vPtArr

                 Set swComp = pt

                    If Not swComp Is Nothing Then

                        Debug.Print "  " & swComp.Name2 & " --> " & swComp.GetPathName

                    Else

                       Debug.Print "  Could not get component."

                 End If

                Next

                

                swFeatData.ReleaseSelectionAccess

                

            End If

        Set swFeat = swFeat.GetNextFeature

    Loop

Exit Sub

 

ErrorHandler:

Debug.Print Err.Description

Resume Next

End Sub



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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Hole Series Information Example (VBA)
*Comment:  
*   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:

x

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
x

Web Help Content Version: API Help (English only) 2012 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.