AnsweredAssumed Answered

Get thickness of sheetmetal part without selecting any face

Question asked by Yash Kothari on May 23, 2018
Latest reply on May 28, 2018 by Nilesh Patel
Branched to a new discussion

I am working on a program to save DXF file into separate thickness wise folders(if it is there else create new folder). To get started i first need to get the thickness of part, and for that i found a program from one of forums, but when i select any face other than the base flange face, it gives me debug error, I am thinking if i can get the thickness without selecting any face. The program is:


Option Explicit

Sub main()

    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim vConfNameArr            As Variant
    Dim sConfigName             As String
    Dim nStart                  As Single
    Dim i                       As Long
    Dim bShowConfig             As Boolean
    Dim bRebuild                As Boolean
    Dim bRet                    As Boolean
    Dim swsel As SldWorks.SelectionMgr
    Dim swface As SldWorks.Face2
    Dim swfeature As SldWorks.Feature
    Dim swfeaturedata As Object
    Dim Thickness As String

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swsel = swModel.SelectionManager
    Set swface = swsel.GetSelectedObject(1)
    Set swfeature = swface.GetFeature
    Set swfeaturedata = swfeature.GetDefinition

    Thickness = swfeaturedata.Thickness

    swApp.SendMsgToUser "Sheet Thickness" & " " & Thickness * 1000 & "mm"


    vConfNameArr = swModel.GetConfigurationNames

    For i = 1 To UBound(vConfNameArr)

        sConfigName = vConfNameArr(i)

bShowConfig = swModel.ShowConfiguration2(sConfigName)

bRebuild = swModel.ForceRebuild3(False)

Dim FilePath As String
Dim PathSize As Long
Dim PathNoExtension As String
Dim NewFilePath As String

FilePath = swModel.GetPathName
PathSize = Strings.Len(FilePath)
PathNoExtension = Strings.Left(FilePath, PathSize - 6)

NewFilePath = PathNoExtension + sConfigName & ".DXF"

'Export Flat Pattern
bRet = swModel.ExportFlatPatternView(NewFilePath, swExportFlatPatternOption_None)

Next i

End Sub


I succeeded in getting sheet thickness, but i want it without selecting any face.