Export all iPart variants




VBA
Sub Export()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oFactory As iPartFactory
Set oFactory = oDoc.ComponentDefinition.iPartFactory
Dim tRow As iPartTableRow
For Each tRow In oFactory.TableRows
    If Not tRow Is Nothing Then
        Dim oPartMember As iPartMember
        Set oPartMember = oFactory.CreateMember(tRow)
        Dim oPart As PartDocument
        Set oPart = oPartMember.Parent.Document
        Call oPart.SaveAs("C:/temp/" + tRow.Item(1).Value + ".stp", True)
    End If
Next
End Sub

The process is straightforward. Firstly, obtain a reference to the part document and then use it to access the iPart factory. From the factory, we iterate through each row generated in the iPart table. When using a ‘for’ statement, the first row may be empty, so an ‘if’ statement is utilized to skip it. For every other row, we proceed to create the member and then save it in our desired file type.

The ‘CreateMember’ function generates the .ipt file, while ‘SaveAs’ generates the .stp file.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *