<?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 Re: Part Numbers of Content Center Parts in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208466#M181261</link>
    <description>&lt;P&gt;Maybe try updating the assembly file along with the parts.&lt;/P&gt;&lt;P&gt;We had a similar problem and from what I remember we had to uncheck a frame generator setting. attached&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jul 2026 14:40:37 GMT</pubDate>
    <dc:creator>dalton_northwind</dc:creator>
    <dc:date>2026-07-22T14:40:37Z</dc:date>
    <item>
      <title>Part Numbers of Content Center Parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14205601#M181237</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I usually give Part Numbers to Parts through the BOM. The CC parts always rename "Part Number" by their defaults if there are any changes. For this reason I create an additional iProperty "Number" which stores the "Part Number" value so that it doesn't dissapear after every change. Then I have to again set Part Number = &amp;lt;Number&amp;gt; in BOM to fix the issue.&lt;/P&gt;&lt;P&gt;I wrote this little code to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;unmerge BOM&lt;/LI&gt;&lt;LI&gt;set Part Number =&amp;lt;Number&amp;gt; (yes I even tried giving it a copied valued instead of formula)&lt;/LI&gt;&lt;LI&gt;re-merge BOM&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But it still doesn't work. The part's which are of same stock size and same length still cause issues.&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emanuelc_0-1784556881520.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1651779i45B7F0DCCBFB1B16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emanuelc_0-1784556881520.png" alt="emanuelc_0-1784556881520.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I manually un-merge and I have this (none of the parts are named the same):&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emanuelc_1-1784556913362.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1651780i9E5B93C844F0CED4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emanuelc_1-1784556913362.png" alt="emanuelc_1-1784556913362.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I retype the Number values - same values as before (essentially 'dirtying' the part) and everything works well.&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emanuelc_2-1784556999766.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1651784i79CF70AD33A32B13/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emanuelc_2-1784556999766.png" alt="emanuelc_2-1784556999766.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can this be fixed? I tried "dirtying" the part through the code with:&amp;nbsp;oRefDoc.Dirty = True, oRefDoc.Update() but without any success...&lt;/P&gt;&lt;P&gt;Here is the code. Many thanks!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="general"&gt;Sub Main()

    Dim oAsmDoc As Document = ThisApplication.ActiveDocument

    If oAsmDoc.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
        MessageBox.Show("Run this rule on an ASSEMBLY document. Exiting...", "ERROR",
                        MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    ' Disable merge before updating Part Numbers
    Bom_DisableMerge(oAsmDoc)

    ' Update Part Numbers from iProperty "Number"
    UpdatePartNumbersFromNumber(oAsmDoc)

    ' Re-enable merge
    Bom_EnableMerge(oAsmDoc)

End Sub

Public Sub Bom_DisableMerge(oAsmDoc As AssemblyDocument)

    Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM
    oBOM.PartsOnlyViewEnabled = True

    ' Disable "Merge Rows on Part Number Match"
    oBOM.SetPartNumberMergeSettings2(False, Nothing, Nothing)

End Sub

Public Sub Bom_EnableMerge(oAsmDoc As AssemblyDocument)

    Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM
    oBOM.PartsOnlyViewEnabled = True

    ' Enable "Merge Rows on Part Number Match"
    oBOM.SetPartNumberMergeSettings2(True, Nothing, Nothing)

End Sub

Public Sub UpdatePartNumbersFromNumber(oAsmDoc As AssemblyDocument)

    For Each oRefDoc As Document In oAsmDoc.AllReferencedDocuments

        ' Skip non‑modifiable and non‑real BOM parts
        If Not oRefDoc.IsModifiable Then Continue For
        If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then Continue For
        If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then Continue For

        ' Get custom property set
        Dim oCustom As PropertySet
        Try
            oCustom = oRefDoc.PropertySets("Inventor User Defined Properties")
        Catch
            ' No custom props → skip
            Continue For
        End Try

        ' Try to get "Number"
        Dim numberValue As String
        Try
            numberValue = CStr(oCustom("Number").Value)
        Catch
            'MessageBox.Show("Didn't work for: " &amp;amp; oRefDoc.DisplayName &amp;amp; " (no 'Number' iProperty)")
            Continue For
        End Try

        If Trim(numberValue) = "" Then Continue For

        ' *** FORCE REFRESH OF NUMBER ***
        oCustom("Number").Value = numberValue

        ' *** Assign formula-style reference to Part Number ***
        Dim oPNProp As Object
        Try
            oPNProp = oRefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number")
            oPNProp.Value = "=&amp;lt;Number&amp;gt;"
        Catch
            'MessageBox.Show("Didn't work for: " &amp;amp; oRefDoc.DisplayName &amp;amp; " (no 'Part Number' iProperty)")
            Continue For
        End Try

    Next

End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 20 Jul 2026 14:19:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14205601#M181237</guid>
      <dc:creator>emanuel.c</dc:creator>
      <dc:date>2026-07-20T14:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Part Numbers of Content Center Parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208466#M181261</link>
      <description>&lt;P&gt;Maybe try updating the assembly file along with the parts.&lt;/P&gt;&lt;P&gt;We had a similar problem and from what I remember we had to uncheck a frame generator setting. attached&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 14:40:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208466#M181261</guid>
      <dc:creator>dalton_northwind</dc:creator>
      <dc:date>2026-07-22T14:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: Part Numbers of Content Center Parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208698#M181266</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/17859314"&gt;@dalton_northwind&lt;/a&gt;&amp;nbsp;Thank you so much!! I can't believe I've been using Inventor for so many years and never knew of those settings! That auto renaming was always a frustration. I'll call this solved.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 17:26:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208698#M181266</guid>
      <dc:creator>emanuel.c</dc:creator>
      <dc:date>2026-07-22T17:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Part Numbers of Content Center Parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208708#M181267</link>
      <description>&lt;P&gt;Meanwhile I was able to adapt the code using Rebuild and Refresh on the BOM. If it's useful to anyone, here it is:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()

    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument

    If oAsmDoc.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
        MessageBox.Show("Run this rule on an ASSEMBLY document. Exiting...", "ERROR",
                        MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If
	
    ' 1. Disable merge before updating Part Numbers
    Bom_DisableMerge(oAsmDoc)

    ' 2. Update Part Numbers from iProperty "Number"
    UpdatePartNumbersFromNumber(oAsmDoc)

    ' 3. Force assembly update AFTER parts update
    Try : oAsmDoc.Update2(True) : Catch : End Try

    ' 4. Full BOM rebuild sequence
    RebuildBOM(oAsmDoc)

    ' 5. Re-enable merge
    Bom_EnableMerge(oAsmDoc)

    ' 6. Final assembly update
    Try : oAsmDoc.Update2(True) : Catch : End Try

End Sub


' DISABLE MERGE
Public Sub Bom_DisableMerge(oAsmDoc As AssemblyDocument)

    Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM
    oBOM.PartsOnlyViewEnabled = True

    oBOM.SetPartNumberMergeSettings2(False, Nothing, Nothing)

End Sub


' ENABLE MERGE
Public Sub Bom_EnableMerge(oAsmDoc As AssemblyDocument)

    Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM
    oBOM.PartsOnlyViewEnabled = True

    oBOM.SetPartNumberMergeSettings2(True, Nothing, Nothing)

End Sub


' UPDATE PART NUMBERS FROM "Number"
Public Sub UpdatePartNumbersFromNumber(oAsmDoc As AssemblyDocument)

    For Each oRefDoc As Document In oAsmDoc.AllReferencedDocuments

        If Not oRefDoc.IsModifiable Then Continue For
        If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kPhantomBOMStructure Then Continue For
        If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then Continue For

        Dim oCustom As PropertySet
        Try
            oCustom = oRefDoc.PropertySets("Inventor User Defined Properties")
        Catch
            Continue For
        End Try

        Dim numberValue As String
        Try
            numberValue = CStr(oCustom("Number").Value)
        Catch
            Continue For
        End Try

        If Trim(numberValue) = "" Then Continue For

        ' Refresh Number
        oCustom("Number").Value = numberValue

        ' Assign formula Part Number
        Dim oPNProp As Object
        Try
            oPNProp = oRefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number")
            oPNProp.Value = "=&amp;lt;Number&amp;gt;"
        Catch
            Continue For
        End Try

        ' Dirty the document
        oRefDoc.Dirty = True

        ' Force iProperty evaluator
        Try : oRefDoc.PropertySets.Flush() : Catch : End Try

        ' Rebuild geometry
        Try : oRefDoc.ComponentDefinition.Update() : Catch : End Try

        ' Update document
        Try : oRefDoc.Update2(True) : Catch : End Try

        ' ⭐ CRITICAL ⭐ Save forces formula evaluation
        Try : oRefDoc.Save() : Catch : End Try

    Next

End Sub


' FULL BOM REBUILD SEQUENCE
Public Sub RebuildBOM(oAsmDoc As AssemblyDocument)

    Dim oBOM As BOM = oAsmDoc.ComponentDefinition.BOM

    ' Ensure BOM views are enabled
    oBOM.PartsOnlyViewEnabled = True
    oBOM.StructuredViewEnabled = True

    Dim oStructured As BOMView
    Dim oPartsOnly As BOMView

    Try
        oStructured = oBOM.BOMViews.Item("Structured")
        oPartsOnly = oBOM.BOMViews.Item("Parts Only")
    Catch
        Exit Sub
    End Try

    ' Rebuild both views
    Try : oStructured.Rebuild() : Catch : End Try
    Try : oPartsOnly.Rebuild() : Catch : End Try

    ' Refresh both views
    Try : oStructured.Refresh() : Catch : End Try
    Try : oPartsOnly.Refresh() : Catch : End Try

    ' Update assembly
    Try : oAsmDoc.Update2(True) : Catch : End Try

End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Jul 2026 17:30:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/part-numbers-of-content-center-parts/m-p/14208708#M181267</guid>
      <dc:creator>emanuel.c</dc:creator>
      <dc:date>2026-07-22T17:30:33Z</dc:date>
    </item>
  </channel>
</rss>

