Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am developing a rule shown below to extract all the data required for the product documentation in huge assembly environment (couple of thousand drawings).
The rule has following functionalities:
- reference documents (parts and assemblies) excluded
- phantom parts excluded
- phantom assemblies excluded
However, I still have a problem connected with some parts reside in one or multiple phantom parents. If the parent of a document (part) is of phantom BOM structure, the true parent of the document is the parent of parent and so on until the parent of normal BOM structure is hit.
From my side, if I know the parent of parent, I can get around this issue (at the bottom of this rule). But, it looks like a lot to do!
Could you help, please. Thanks.
Public Class RWEI_0010BOM Shared oTextSave As String = "C:\Users\Public\Documents\iLogicBuffer.txt" Sub Main Dim oAssy_ThisDoc As AssemblyDocument Dim oDoc As Document = ThisApplication.ActiveDocument Dim iL_NO As String = "0010-BOM" oDelete_ex_Notepad(oTextSave, iL_NO) Dim HL1_Prefix As String = "FILE REFERENCE TREE RAN FROM: " oHL1 = HL1_Prefix & oDoc.FullFileName oWrite_HeaderLines(oTextSave, oHL1) Dim iL_Name As String = "All Occurrences with BOM Structure" Dim oHL2 As String = "Rule " & iL_NO & ": " & iL_Name oWrite_HeaderLines(oTextSave, oHL2) Dim oDashes As String = "" For i = 1 To Len(oHL2) oDashes = oDashes & "-" Next i Dim oHL3 As String = oDashes oWrite_HeaderLines(oTextSave, oHL3) Dim oHL4 As String = "" oWrite_HeaderLines(oTextSave, oHL4) Dim oBOM As BOM oBOM = ThisApplication.ActiveDocument.ComponentDefinition.BOM Dim oBOMView As BOMView oBOMView = oBOM.BOMViews.Item("Unnamed")'Accesing to Model data Column 'In English__"Unnamed"_"Structured"_"Parts Only"__In Spanish__"Sin nombre"_"Estructurado"_"Solo piezas" Call ListItems(oBOMView.BOMRows, 0) Process.Start("Notepad.exe", oTextSave) End Sub Sub ListItems(Rows As BOMRowsEnumerator, indent As Integer) Dim oBOMRow As BOMRow For Each oBOMRow In Rows Dim oDef As ComponentDefinition oDef = oBOMRow.ComponentDefinitions(1) Dim oLFN As String oLFN = oDef.Document.Displayname Dim oDocFile As Document oDocFile = oDef.Document If oDocFile.IsModifiable = True Then Dim oBOMStructnumber As String oBOMStructnumber = oBOMRow.BOMStructure Dim BOM_Structure As String If oBOMStructnumber <> 51972 Then If oBOMStructnumber = 51969 Then BOM_Structure = "Default" If oBOMStructnumber = 51974 Then BOM_Structure = "Inseparable" If oBOMStructnumber = 51970 Then BOM_Structure = "Normal" If oBOMStructnumber = 51971 Then BOM_Structure = "Phantom" If oBOMStructnumber = 51973 Then BOM_Structure = "Purchased" If oBOMStructnumber = 51972 Then BOM_Structure = "Reference" If oBOMStructnumber = 51975 Then BOM_Structure = "The Structure Type varies amongst references" ' Dim oDocFile As Document ' oDocFile = oDef.Document ' If oDocFile.IsModifiable = True Then Dim Parent As Document = oDocFile.ReferencingDocuments.Item(1) If Not oBOMRow.ChildRows Is Nothing Then Call ListItems(oBOMRow.ChildRows, indent + 1) End If Dim oPhantomPart_ParentOfPhantomPart As String = "" If Right(oLFN, 3) = "ipt" And BOM_Structure = "Phantom" Then 'Do nothing Else If Right(oLFN, 3) = "iam" And BOM_Structure = "Phantom" Then 'Do nothing Else If Right(oLFN, 3 = "ipt" And BOM_Structure = "Phantom" Then
'oPhantomPart_ParentOfPhantomPart = oLFN & "$" & Parent.DisplayName Else oName_Parent = Parent.DisplayName & "$" & BOM_Structure & "$" & oLFN oWrite_Data(oTextSave, oName_Parent) End If End If End If End If Next End Sub Sub oWrite_HeaderLines(oTextSave As String, oHeaderLine As String) oWrite = System.IO.File.AppendText(oTextSave) oWrite.WriteLine(oHeaderLine) oWrite.Flush() oWrite.Close End Sub Sub oWrite_Data(oTextSave As String, oData As String) oWrite = System.IO.File.AppendText(oTextSave) oWrite.WriteLine(oData) oWrite.Flush() oWrite.Close End Sub Sub oDelete_ex_Notepad(oTextSave As String, iL_NO As String) 'To delete oTextSave if existing. If System.IO.File.Exists(oTextSave) = True Then System.IO.File.Delete(oTextSave) End If End Sub End Class
Solved! Go to Solution.