create all iassembly members part lists in drawing

create all iassembly members part lists in drawing

anandaraj.ganesanGP4H9
Participant Participant
197 Views
1 Reply
Message 1 of 2

create all iassembly members part lists in drawing

anandaraj.ganesanGP4H9
Participant
Participant

Hello Experts,

 

I have had a frequent task that is to place part lists for iassembly in the new drawing. iassembly may have N number of instances on it. I was getting tried on coping part list and enabling the configuration one by one. Can anyone help me with a ilogic code that can place all instance part lists in one shot.

 

Thank you and appreciate 

0 Likes
198 Views
1 Reply
Reply (1)
Message 2 of 2

Ralf_Krieg
Advisor
Advisor

Hello

 

If there is a drawing view on the sheet with one of the iAssembly members, the following VBA could work.

Option Explicit

Private Sub iAssPartsLists()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet

Dim oView As DrawingView
Set oView = oSheet.DrawingViews(1)

Dim oRefedDoc As AssemblyDocument
Set oRefedDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oCompDef As AssemblyComponentDefinition
Set oCompDef = oRefedDoc.ComponentDefinition

Dim oPoint As Point2d
Dim i As Integer
Dim aMemberFiles()

Dim oIAssFactory As iAssemblyFactory
If oCompDef.IsiAssemblyMember Then
    Set oIAssFactory = oCompDef.iAssemblyMember.Row.Parent
    
    Dim oFileNameColumn As iAssemblyTableColumn
    Set oFileNameColumn = oIAssFactory.FileNameColumn
    
    ReDim Preserve aMemberFiles(oFileNameColumn.Count - 1)
    For i = 0 To oFileNameColumn.Count - 1
        aMemberFiles(i) = oFileNameColumn.item(i + 1).Value
    Next
    
    For i = 0 To UBound(aMemberFiles) - 1
        Set oPoint = insertpartslist(oSheet, oView, aMemberFiles(i), oPoint) 'oCell.Value, oPoint)
    Next
End If
End Sub

Private Function insertpartslist(ByVal oSheet As Sheet, ByVal oView As DrawingView, ByVal sMembername As String, Optional ByVal oPoint As Point2d = Nothing) As Point2d
    
    If oPoint Is Nothing Then Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width - 1, oSheet.Height - 1)
    Dim oLevel As PartsListLevelEnum
    oLevel = kStructuredAllLevels 'kFirstLevelComponents, kPartsOnly, kStructured
    
    Dim aMembers(0) As String
    aMembers(0) = sMembername
    Dim oPartsList As PartsList
    Set oPartsList = oSheet.PartsLists.Add(oView, oPoint, oLevel)
    oPartsList.MembersToInclude = aMembers

    oPoint.Y = oPoint.Y - oPartsList.RangeBox.MaxPoint.Y + oPartsList.RangeBox.MinPoint.Y
    Set insertpartslist = oPoint
End Function

 


R. Krieg
RKW Solutions
www.rkw-solutions.com