The following code will generate the structure for a DXF file, from a template.
Function fFile_load are not supplied, but it loads a text file as a bunch of lines (search the web for procedures to achieve this task) .
Option Explicit Private Type tSeed Id As String Type As String Line As Long End Type Private Type tDependency Id As String Element As String Parent As String Line As Long End Type Sub sMacro1() 'Call stx_Profile_Fast Dim aLine() As String Dim aSeed() As tSeed Dim aDependency() As tDependency Dim lgLine As Long Dim lgZero As Long Dim lgSeed As Long Dim lgDependency As Long Dim Code As Integer Dim strText As String Dim aStopper() As String Dim lgStopper As Long lgSeed = g_Base - 1 lgDependency = g_Base - 1 ReDim Preserve aStopper(g_Base To g_Base) aStopper(g_Base) = "EOF" 'Stoppers: "EOF|ENDSEC|ENDTAB|ENDBLK|SEQEND" aLine() = fFile_Load(vba.environ("UserProfile") & "\Documents\#test.dxf") Stop For lgLine = LBound(aLine) To UBound(aLine) Step 2 Code = VBA.CLng(aLine(lgLine)) If Code = 0 Then strText = aLine(lgLine + 1) 'If Not (Not aStopper) Then For lgStopper = LBound(aStopper) To UBound(aStopper) If aStopper(lgStopper) = strText Then Exit For Next lgStopper 'End If If lgStopper > UBound(aStopper) Then If strText Like "*END*" Then ReDim Preserve aStopper(g_Base To lgStopper) aStopper(lgStopper) = strText End If End If End If Next lgLine For lgLine = LBound(aLine) To UBound(aLine) Step 2 Code = VBA.CLng(aLine(lgLine)) If Code = 5 Then lgSeed = lgSeed + 1 ReDim Preserve aSeed(g_Base To lgSeed) With aSeed(lgSeed) .Id = aLine(lgLine + 1) ' Find the 0 backwards (will set the Entity declaration) For lgZero = lgLine To LBound(aLine) Step -2 If VBA.CLng(aLine(lgZero)) = 0 Then .Type = aLine(lgZero + 1) ' Store ending with "§" if more than one of this item Dim lgItem As Long Dim aItem() As String For lgItem = LBound(aItem) To lgSeed - 1 If aItem(lgItem) = aSeed(lgSeed).Type Then aItem(lgItem) = aSeed(lgSeed).Type & "§" ' more than one of these Exit For ElseIf aItem(lgItem) Like aSeed(lgSeed).Type & "§" Then aItem(lgItem) = aSeed(lgSeed).Type ' more than one of these Exit For End If Next lgItem Exit For End If Next lgZero .Line = lgLine + 1 End With End If Next lgLine ' Once we have located the seeds, find dependencies For lgLine = LBound(aLine) To UBound(aLine) Step 2 Code = VBA.CLng(aLine(lgLine + 0)) strText = aLine(lgLine + 1) If 320 <= Code And Code <= 369 Then 'Search for this code in all aSeed lgDependency = lgDependency + 1 ReDim Preserve aDependency(g_Base To lgDependency) With aDependency(lgDependency) .Id = aLine(lgLine + 1) .Line = lgLine + 1 ' Find the 0 backwards (will set the Entity declaration) For lgZero = lgLine To LBound(aLine) Step -2 If VBA.CLng(aLine(lgZero)) = 0 Then .Element = aLine(lgZero + 1) Exit For End If Next lgZero ' Search for seed parent item/entity For lgSeed = LBound(aSeed) To UBound(aSeed) If aSeed(lgSeed).Id = strText Then .Parent = aSeed(lgSeed).Type .Line = aSeed(lgSeed).Line Exit For End If Next lgSeed End With End If strText = aLine(lgLine + 1) Next lgLine Stop End SubNow you have more than a guess to find what seed is linked to what entity.