Hide Table of Contents

Traverse All Cosmetic Threads Example (VB.NET)

This example shows how to traverse all cosmetic threads in a part and extract their data.

NOTE: In a part or assembly, a cosmetic thread is a subfeature of a hole or cut extrusion. Thus, you can traverse all of the cosmetic threads in a model using the IFeature traversal methods.

'---------------------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\tutorial\api\holecube.sldprt.
' 2. Open an Immediate window.
'
' Postconditions:
' 1. Creates a Helicoil Metric standard cosmetic thread.
' 2. Examine the Immediate window.
'
' NOTE: Because the part is used elsewhere, do not save changes.
'---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics


Partial Class SolidWorksMacro

    
Sub main()

        
Dim swModel As ModelDoc2
        
Dim swFeat As Feature
        
Dim swSubFeat As Feature
        
Dim sFeatType As String
        Dim swCosThread As CosmeticThreadFeatureData
        
Dim bRet As Boolean

        swModel = swApp.ActiveDoc

        bRet = swModel.Extension.SelectByID2(
"", "EDGE", -0.000802489357837999, -0.0246888176810671, 0.0000600726028778809, True, 0, Nothing, 0)
        swFeat = swModel.FeatureManager.InsertCosmeticThread3(swCosmeticStandardType_e.swStandardType_StandardHelicoilMetric,
"Helicoil threads", "M33x2.0", 0.033, swCosmeticEndConditions_e.swEndConditionBlind2Dia, 0.025, "M33x2.0 Helicoil Threads")

        Debug.Print(
"File = " & swModel.GetPathName)

        swFeat = swModel.FirstFeature

        
Do While Not swFeat Is Nothing
            swSubFeat = swFeat.GetFirstSubFeature
            
Do While Not swSubFeat Is Nothing
                sFeatType = swSubFeat.GetTypeName

                
Select Case sFeatType

                    
Case "CosmeticThread"
                        Debug.Print("    " & swSubFeat.Name & " [" & sFeatType & "]")

                        swCosThread = swSubFeat.GetDefinition

                        Debug.Print(
"      ApplyThread      = " & swCosThread.ApplyThread)
                        Debug.Print(
"      BlindDepth       = " & swCosThread.BlindDepth * 1000.0# & " mm")
                        Debug.Print(
"      Diameter         = " & swCosThread.Diameter * 1000.0# & " mm")
                        Debug.Print(
"      DiameterType     = " & swCosThread.DiameterType)
                        Debug.Print(
"      ThreadCallout    = " & swCosThread.ThreadCallout)
                        Debug.Print(
"      ConfigurationOption as defined in swCosmeticConfigOptions_e = " & swCosThread.ConfigurationOption)
                        Debug.Print(
"      EndCondition as defined in swCosmeticEndConditions_e = " & swCosThread.EndCondition)
                        Debug.Print(
"      Size = " & swCosThread.Size)
                        Debug.Print(
"      Standard as defined in swCosmeticStandardType_e = " & swCosThread.Standard)
                        Debug.Print(
"      StandardType = " & swCosThread.StandardType)


                        Debug.Print(
"")

                
End Select

                swSubFeat = swSubFeat.GetNextSubFeature

            
Loop

            swFeat = swFeat.GetNextFeature

        
Loop

    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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Traverse All Cosmetic Threads Example (VB.NET)
*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) 2017 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.