To generate the render featured on the Tabulated designs with iPart page, I had to create and export all the members of the iPart. To save myself from a monotonous and repetitive task, I developed a small macro to handle the file exports instead.
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.
![](/wp-content/uploads/2023/11/Pully-iPart-1-1024x553.png)
Leave a Reply