ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
KCKevin Chisholm07/02/2017

Hi everyone,

I was wondering if anyone has seen a macro to export all the

bodies of a weldment part to step files. I'm looking at naming the

step files as per the weldment cut list item number but haven't found

anything.

Exemple of what needed:

     1- Part number is T-001122 with 3 bodies.

     2- Step of body 1 export to T-001122-Item1.STEP

     3- Step of body 2 export to T-001122-Item2.STEP

     4- Step of body 3 export to T-001122-Item3.STEP.

Not sure if this is possible but you can get the BOM item number with this:

Sub ProcessTableAnn(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swTableAnn As SldWorks.TableAnnotation, ConfigName As String)

    Dim nNumRow As Long

    Dim J As Long

    Dim I As Long

    Dim ItemNumber As String

    Dim PartNumber As String

    Debug.Print "   Table Title        " & swTableAnn.Title

    nNumRow = swTableAnn.RowCount

    Dim swBOMTableAnn As BomTableAnnotation

    Set swBOMTableAnn = swTableAnn

    For J = 0 To nNumRow - 1

        Debug.Print "   Row Number " & J & " Component Count  : " & swBOMTableAnn.GetComponentsCount2(J, ConfigName, ItemNumber, PartNumber)

        Debug.Print "       Item Number  : " & ItemNumber

        Debug.Print "       Part Number  : " & PartNumber

       

        Dim vPtArr As Variant

        Dim swComp As Object

        Dim pt As Object

        Dim compPath As String

        vPtArr = swBOMTableAnn.GetComponents2(J, ConfigName)

        If (Not IsEmpty(vPtArr)) Then

            For I = 0 To UBound(vPtArr)

                Set pt = vPtArr(I)

                Set swComp = pt

                If Not swComp Is Nothing Then

                    Debug.Print "           Component Name :" & swComp.Name2 & "      Configuration Name : " & swComp.ReferencedConfiguration

                    Debug.Print "           Component Path :" & swComp.GetPathName

                Else

                    Debug.Print "  Could not get component."

                End If

            Next

        End If

    Next J

End Sub

Well hope someone can help me out!

Thanks for any help!

Kevin Chisholm