<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic VBA Edit BOM in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7686934#M94057</link>
    <description>&lt;P&gt;I'm trying to write a VBA maacro, which when launched in an assembly will go&amp;nbsp; through the BOM and modify the part number of each component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some components have "." in the part number, I need to remove "." and everything after it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't figure out where the "part number" property resides&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub CleanWireBOM()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    Dim oBOM As BOM
    Set oBOM = asmDoc.ComponentDefinition.BOM
    oBOM.StructuredViewFirstLevelOnly = False
    oBOM.StructuredViewEnabled = True
    Dim oStructuredBOMView As BOMView
    Set oStructuredBOMView = oBOM.BOMViews.Item("Structured")
    Dim oBOMRow As BOMRow
    
    For Each oBOMRow In oStructuredBOMView.BOMRows
        Dim oCompDef As ComponentDefinition
        Dim PartNum As String
        PartNum =  ?????
        
    Next
End Sub&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Jan 2018 20:43:21 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-12T20:43:21Z</dc:date>
    <item>
      <title>VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7686934#M94057</link>
      <description>&lt;P&gt;I'm trying to write a VBA maacro, which when launched in an assembly will go&amp;nbsp; through the BOM and modify the part number of each component.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some components have "." in the part number, I need to remove "." and everything after it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't figure out where the "part number" property resides&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub CleanWireBOM()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    Dim oBOM As BOM
    Set oBOM = asmDoc.ComponentDefinition.BOM
    oBOM.StructuredViewFirstLevelOnly = False
    oBOM.StructuredViewEnabled = True
    Dim oStructuredBOMView As BOMView
    Set oStructuredBOMView = oBOM.BOMViews.Item("Structured")
    Dim oBOMRow As BOMRow
    
    For Each oBOMRow In oStructuredBOMView.BOMRows
        Dim oCompDef As ComponentDefinition
        Dim PartNum As String
        PartNum =  ?????
        
    Next
End Sub&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jan 2018 20:43:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7686934#M94057</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-12T20:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7687145#M94058</link>
      <description>&lt;P&gt;this should do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub CleanWireBOM()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    Dim oBOM As BOM
    Set oBOM = asmDoc.ComponentDefinition.BOM
    oBOM.StructuredViewFirstLevelOnly = False
    oBOM.StructuredViewEnabled = True
    Dim oStructuredBOMView As BOMView
    Set oStructuredBOMView = oBOM.BOMViews.Item("Structured")
    Dim oBOMRow As BOMRow
    
    For Each oBOMRow In oStructuredBOMView.BOMRows
    Dim a As Document
    Set a = oBOMRow.ComponentDefinitions.Item(1).Document
    MsgBox a.FullDocumentName
    
    Dim p As PropertySet
    Set p = a.PropertySets.Item(3)
    
    Dim pr As Property
    Set pr = p.Item("Part Number")
    Dim arr() As String
    On Error Resume Next
    arr = Split(pr.Value, ".", -1)
    Err.Clear
    pr.Value = arr(0)
    a.Save

    Next
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because you asked the BOM iteration.&lt;/P&gt;&lt;P&gt;This can be different the all ref documents!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 22:38:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7687145#M94058</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-01-12T22:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7687147#M94059</link>
      <description>&lt;P&gt;Easier to just iterate through the refdocs...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    Dim oRefDoc As Document

    For each oRefDoc in oDoc.AllReferencedDocuments&lt;BR /&gt;        If oRefDoc.isModifiable = True Then
            oPN = oRefDoc.PropertySets("Design Tracking Properties")("Part Number").Value&lt;BR /&gt;            &lt;BR /&gt;            Dim arr() As String&lt;BR /&gt;
            On Error Resume Next
                arr = Split(oPN, ".", -1)&lt;BR /&gt;                oPN = arr(0)
            Err.Clear&lt;BR /&gt;&lt;BR /&gt;            oRefDoc.PropertySets("Design Tracking Properties")("Part Number").Value = oPN&lt;BR /&gt;        End if&lt;BR /&gt;    Next&lt;BR /&gt;End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2018 22:32:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7687147#M94059</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2018-01-12T22:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7688093#M94060</link>
      <description>&lt;P&gt;Thank you for the quick responses. The code works well for regular parts &amp;amp; assemblies but not for cable/harness (which is what I was hoping to use it for).&lt;/P&gt;&lt;P&gt;My assembly consists of:&lt;/P&gt;&lt;P&gt;Connector1&lt;/P&gt;&lt;P&gt;Connector2&lt;/P&gt;&lt;P&gt;Cable1&lt;/P&gt;&lt;P&gt;&amp;nbsp;-&amp;gt; Wire1&lt;/P&gt;&lt;P&gt;&amp;nbsp;-&amp;gt; Wire2&lt;/P&gt;&lt;P&gt;&amp;nbsp;-&amp;gt; Wire3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cable1 is set to "Phantom" in the BOM to promote the individual wires.&lt;/P&gt;&lt;P&gt;When I run the code with a debug statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Debug.Print oBOMRow.ItemNumber, "-", pr.Value, vbCr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1             -             C1            

2             -             Cable1        

3             -             Cable1        

4             -             Cable1        &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the individual wires don't have their own "documents". So how can I access their part numbers?&lt;/P&gt;&lt;P&gt;Same thing happens if I add a "Virtual" component to the top level assembly. The code doesn't pick up it's part number.&lt;/P&gt;&lt;P&gt;I have tried setting the BOM to both "Structured" and "Parts Only" but the results is the same.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jan 2018 17:30:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7688093#M94060</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-13T17:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7688589#M94061</link>
      <description>&lt;P&gt;Try this then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;Sub CleanWireBOM()
    Dim asmDoc As AssemblyDocument
    Set asmDoc = ThisApplication.ActiveDocument
    
    Dim oBom As BOM
    Set oBom = asmDoc.ComponentDefinition.BOM
    oBom.StructuredViewEnabled = True
    oBom.StructuredViewFirstLevelOnly = False
    Dim oBOMView As BOMView
    Set oBOMView = oBom.BOMViews(2)
    
    Dim compDef As ComponentDefinition
    Dim doc As Document
    Dim row As BOMRow
    Dim prop As Property
    For Each row In oBOMView.BOMRows
        Set compDef = row.ComponentDefinitions(1)
        Set doc = compDef.Document
        If compDef.Type = kVirtualComponentDefinitionObject Then
            Set prop = compDef.PropertySets("Design Tracking Properties")("Part Number")
        Else
            Set prop = doc.PropertySets("Design Tracking Properties")("Part Number")
        End If
        
        If doc.IsModifiable Then
            If prop.Value &amp;lt;&amp;gt; "" Then prop.Value = Split(prop.Value, ".")(0)
        End If
    Next
End Sub&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Jan 2018 05:52:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/7688589#M94061</guid>
      <dc:creator>smilinger</dc:creator>
      <dc:date>2018-01-14T05:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/8705050#M94062</link>
      <description>&lt;P&gt;Hello there!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far I haven't been able to find a tutorial or instructions on how to do a BOM modification and this thread is the closest thing I have found so far&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see my picture:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically,&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/622115i0D13BE93057BE7A0/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt; if we have 2 E-stops, BOM will list it as:&lt;/P&gt;
&lt;P&gt;Main-Estop&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 800T-FX6A5&amp;nbsp; &amp;nbsp; &amp;nbsp;qty&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAG1&lt;/P&gt;
&lt;P&gt;Panel E-Stop&amp;nbsp; &amp;nbsp; Blank&amp;nbsp; &amp;nbsp; &amp;nbsp; Blank&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAG2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I basically want to do,&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Main-Estop&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 800T-FX6A5&amp;nbsp; &amp;nbsp; &amp;nbsp;qty&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TAG1,TAG2,TAG3 ETC......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can do it manually but it takes a lot of time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help or link will be totally&amp;nbsp;appreciated&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 16:20:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/8705050#M94062</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-03T16:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11612050#M94063</link>
      <description>&lt;P&gt;I need to code by&amp;nbsp;&lt;SPAN&gt;Inventor iLogic rules ，Would you do me a favor?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 09:30:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11612050#M94063</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-11T09:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11612408#M94064</link>
      <description>&lt;P&gt;Use find and replace tool to remove the word "Set".&lt;/P&gt;&lt;P&gt;Create a sub routine called Sub Main and set up like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="courier new,courier"&gt;Sub Main&lt;BR /&gt;CleanWireBOM()&lt;BR /&gt;End Sub&lt;BR /&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 15:36:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11612408#M94064</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-12-11T15:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615810#M94065</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lihouxin065_0-1670894028422.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1151702i9966BC2C8C58B593/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lihouxin065_0-1670894028422.png" alt="lihouxin065_0-1670894028422.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 01:14:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615810#M94065</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-13T01:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615818#M94066</link>
      <description>&lt;P&gt;Sub Main CleanWireBOM() End Sub Sub CleanWireBOM() Dim asmDoc As AssemblyDocument asmDoc = ThisApplication.ActiveDocument Dim oBom As BOM oBom = asmDoc.ComponentDefinition.BOM oBom.StructuredViewEnabled = True oBom.StructuredViewFirstLevelOnly = False Dim oBOMView As BOMView oBOMView = oBom.BOMViews(2) Dim compDef As ComponentDefinition Dim doc As Document Dim row As BOMRow Dim prop As Property For Each row In oBOMView.BOMRows compDef = row.ComponentDefinitions(1) doc = compDef.Document If compDef.Type = kVirtualComponentDefinitionObject Then prop = compDef.Propertys("Design Tracking Properties")("Part Number") Else prop = doc.Propertys("Design Tracking Properties")("Part Number") End If If doc.IsModifiable Then If prop.Value &amp;lt;&amp;gt; "" Then prop.Value = Split(prop.Value, ".")(0) End If Next End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 01:22:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615818#M94066</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-13T01:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615853#M94067</link>
      <description>&lt;P&gt;A few things when posting the code you can use the special editor to keep the formatting. See below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AAcheson_0-1670896439061.png" style="width: 364px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1151708i786B440AB819AB7D/image-dimensions/364x373?v=v2" width="364" height="373" role="button" title="AAcheson_0-1670896439061.png" alt="AAcheson_0-1670896439061.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the property object needs a reference to Inventor so write it it in one of two ways&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Inventor.Property&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;[Property]&lt;/LI-CODE&gt;&lt;P&gt;In the find and replace of "Set" it unfortunately took it from "PropertySets" which is required.&amp;nbsp; The below code is functioning.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main 
	CleanWireBOM() 
End Sub 
Sub CleanWireBOM()
	
	Dim asmDoc As AssemblyDocument 
	asmDoc = ThisApplication.ActiveDocument 
	
	Dim oBom As BOM 
	oBom = asmDoc.ComponentDefinition.BOM 
	
	oBom.StructuredViewEnabled = True 
	oBom.StructuredViewFirstLevelOnly = False 
	
	Dim oBOMView As BOMView 
	oBOMView = oBom.BOMViews(2) 
	
	Dim compDef As ComponentDefinition 
	Dim doc As Document 
	Dim row As BOMRow 
	Dim prop As Inventor.Property 
	
	For Each row In oBOMView.BOMRows 
		compDef = row.ComponentDefinitions(1) 
		doc = compDef.Document 
		
		If compDef.Type = kVirtualComponentDefinitionObject Then 
			prop = compDef.PropertySets("Design Tracking Properties")("Part Number") 
		Else 
			prop = doc.PropertySets("Design Tracking Properties")("Part Number") 
		End If 
		If doc.IsModifiable Then 
			If prop.Value &amp;lt;&amp;gt; "" Then prop.Value = Split(prop.Value, ".")(0) 
		End If 
	Next 
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 01:57:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11615853#M94067</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-12-13T01:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11626677#M94068</link>
      <description>&lt;P&gt;Thank you very much for your reply, it looks like it only works for non-virtual parts, not for wires, cables, etc.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20221217194520.png" style="width: 652px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1153654i28E180759AA776EC/image-size/large?v=v2&amp;amp;px=999" role="button" title="20221217194520.png" alt="20221217194520.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 11:46:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11626677#M94068</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-17T11:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627158#M94069</link>
      <description>&lt;P&gt;I think the issue is the nested sub assemblies of the structured BOM. There is no recursion on that rule so anything inside assemblies is ignored. You can use the parts only BOM and effect the parts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change this line from index of 2 to 3 or use the string "Parts Only"&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;oBOMView&lt;/SPAN&gt; = &lt;SPAN&gt;oBom&lt;/SPAN&gt;.&lt;SPAN&gt;BOMViews&lt;/SPAN&gt;(&lt;SPAN&gt;"Parts Only"&lt;/SPAN&gt;) &lt;SPAN&gt;'index 2 is "Structured",'index 3 is "Parts Only"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 19:12:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627158#M94069</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-12-17T19:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627495#M94070</link>
      <description>&lt;P&gt;Thank you for your patient guidance. After making some changes, it will also have an effect on virtual parts. The contents before the first "." from the left in the original part number are retained.&lt;/P&gt;&lt;P&gt;What should I do if I need to retain the content before the first "." from the right?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="clear the contents enclosed by the blue curve" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1153807i0DFBCA59FC974B31/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lihouxin065_0-1671329754129.png" alt="clear the contents enclosed by the blue curve" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;clear the contents enclosed by the blue curve&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main 
	CleanWireBOM() 
End Sub 
Sub CleanWireBOM()
	
	Dim asmDoc As AssemblyDocument 
	asmDoc = ThisApplication.ActiveDocument 
	
	Dim oBom As BOM 
	oBom = asmDoc.ComponentDefinition.BOM 
	
	oBom.StructuredViewEnabled = True 
	oBom.StructuredViewFirstLevelOnly = False 
	oBom.PartsOnlyViewEnabled = True 
	
	Dim oBOMView As BOMView 
	oBOMView = oBom.BOMViews(3) 'index 2 is "Structured",'index 3 is "Parts Only"
	
	Dim compDef As ComponentDefinition 
	Dim doc As Document 
	Dim row As BOMRow 
	Dim prop As Inventor.Property 
	
	For Each row In oBOMView.BOMRows 
		compDef = row.ComponentDefinitions(1) 
		doc = compDef.Document 
		
		If compDef.Type = kVirtualComponentDefinitionObject Then 
			prop = compDef.PropertySets("Design Tracking Properties")("Part Number") 
		Else 
			prop = doc.PropertySets("Design Tracking Properties")("Part Number") 
		End If 
		If doc.IsModifiable Then 
			If prop.Value &amp;lt;&amp;gt; "" Then prop.Value = Split(prop.Value, ".")(0) 
		End If 
	Next 
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Dec 2022 02:19:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627495#M94070</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-18T02:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627683#M94071</link>
      <description>&lt;P&gt;You can remove the Split line and find the location of the right most deliminator then count from the left. Here is a sample. &lt;A href="https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/instrrev-function" target="_blank" rel="noopener"&gt;InStrRev function offical documentation&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim TestText As String = "1234.456.789"
Dim RightDelim As Integer  = InStrRev(TestText, ".")
Dim Value As String = Left(TestText, RightDelim - 1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And here is how it will work in the rule. The only down side, if you run the rule twice you will remove more of the string. A work around could be to count the delimitators from the left if that is consistently 2x&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If doc.IsModifiable Then 
  If prop.Value &amp;lt;&amp;gt; "" Then 
     Dim ChangeText As String = prop.Value
     Dim RightDelim As Integer  = InStrRev(ChangeText, ".")
     If RightDelim &amp;gt; 0 Then
	     prop.Value = Left(ChangeText, RightDelim - 1)
     End If
   End If
End If&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Dec 2022 06:45:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627683#M94071</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-12-18T06:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: VBA Edit BOM</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627906#M94072</link>
      <description>&lt;P&gt;Thank you so much！&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The code can intercept the required characters as expected, but when dealing with the whole BOM, the wires, cables, and some virtual parts by length are merged and retaken in order, some lines are not processed after running the code.&lt;/P&gt;&lt;P&gt;How should I fix this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="before  running the code" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1153867i864381A73DE2C7F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="before.png" alt="before  running the code" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;before  running the code&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="after running the code" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1153870iFEACB5140AB49FE8/image-size/large?v=v2&amp;amp;px=999" role="button" title="After.png" alt="after running the code" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;after running the code&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main 
	CleanWireBOM()
	MessageBox.Show("Done", "CleanWireBOM")

End Sub 
Sub CleanWireBOM()
	
	Dim asmDoc As AssemblyDocument 
	asmDoc = ThisApplication.ActiveDocument 
	
	Dim oBom As BOM 
	oBom = asmDoc.ComponentDefinition.BOM 
	
	oBom.StructuredViewEnabled = True 
	oBom.StructuredViewFirstLevelOnly = False 
	oBom.PartsOnlyViewEnabled = True 
	
	Dim oBOMView As BOMView 
	oBOMView = oBom.BOMViews(3) 'index 2 is "Structured",'index 3 is "Parts Only"
	
	Dim compDef As ComponentDefinition 
	Dim doc As Document 
	Dim row As BOMRow 
	Dim prop As Inventor.Property 
	
	For Each row In oBOMView.BOMRows 
		compDef = row.ComponentDefinitions(1) 
		doc = compDef.Document 
		
		If compDef.Type = kVirtualComponentDefinitionObject Then 
			prop = compDef.PropertySets("Design Tracking Properties")("Part Number") 
		Else 
			prop = doc.PropertySets("Design Tracking Properties")("Part Number") 
		End If 
		If doc.IsModifiable Then 
		  If prop.Value &amp;lt;&amp;gt; "" Then 
		     Dim ChangeText As String = prop.Value
		     Dim RightDelim As Integer  = InStrRev(ChangeText, ".")
		     If RightDelim &amp;gt; 0 Then
			     prop.Value = Left(ChangeText, RightDelim - 1)
		     End If
		   End If
		End If
	Next 
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Dec 2022 11:07:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/vba-edit-bom/m-p/11627906#M94072</guid>
      <dc:creator>lihouxin065</dc:creator>
      <dc:date>2022-12-18T11:07:21Z</dc:date>
    </item>
  </channel>
</rss>

