<?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>sujet Re: comment recuperer le niveau des enfants dans Inventor - Forum Français</title>
    <link>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/8997359#M5033</link>
    <description>&lt;P&gt;Bonjour,&lt;/P&gt;
&lt;P&gt;Je pense qu'il faut utiliser la nomenclature ou la liste de pièces pour obtenir le niveau des enfants.&lt;/P&gt;
&lt;P&gt;Et exporter le repère pour connaitre le niveau.&lt;/P&gt;
&lt;P&gt;Ci-dessous un exemple de code qui manipule la nomenclature pour débuter tes recherches :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all"&gt;
&lt;DIV id="VBA" class="api-code ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="false" aria-labelledby="ui-id-1"&gt;
&lt;PRE class="api-code"&gt;Public Sub BOMQuery()
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the assembly document.&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' This assumes an assembly document is active.&lt;/SPAN&gt;
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim FirstLevelOnly As Boolean
    If MsgBox("First level only?", vbYesNo) = vbYes Then
        FirstLevelOnly = True
    Else
        FirstLevelOnly = False
    End If
    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the BOM&lt;/SPAN&gt;
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    &lt;SPAN style="color: blue;"&gt;' Set whether first level only or all levels.&lt;/SPAN&gt;
    If FirstLevelOnly Then
        oBOM.StructuredViewFirstLevelOnly = True
    Else
        oBOM.StructuredViewFirstLevelOnly = False
    End If
    
    &lt;SPAN style="color: blue;"&gt;' Make sure that the structured view is enabled.&lt;/SPAN&gt;
    oBOM.StructuredViewEnabled = True
    
    &lt;SPAN style="color: blue;"&gt;'Set a reference to the "Structured" BOMView&lt;/SPAN&gt;
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
        
    Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description"
    Debug.Print "----------------------------------------------------------------------------------"

    &lt;SPAN style="color: blue;"&gt;'Initialize the tab for ItemNumber&lt;/SPAN&gt;
    Dim ItemTab As Long
    ItemTab = -3
    Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab)
End Sub

Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
    ItemTab = ItemTab + 3
    &lt;SPAN style="color: blue;"&gt;' Iterate through the contents of the BOM Rows.&lt;/SPAN&gt;
    Dim i As Long
    For i = 1 To oBOMRows.Count
        &lt;SPAN style="color: blue;"&gt;' Get the current row.&lt;/SPAN&gt;
        Dim oRow As BOMRow
        Set oRow = oBOMRows.Item(i)

        &lt;SPAN style="color: blue;"&gt;'Set a reference to the primary ComponentDefinition of the row&lt;/SPAN&gt;
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)

        Dim oPartNumProperty As Property
        Dim oDescripProperty As Property

        If Typeof oCompDef Is VirtualComponentDefinition Then
            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Part Number"&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'The file property is obtained from the virtual component definition&lt;/SPAN&gt;
            Set oPartNumProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Description"&lt;/SPAN&gt;
            Set oDescripProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
        Else
            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Part Number"&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'The file property is obtained from the parent&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'document of the associated ComponentDefinition.&lt;/SPAN&gt;
            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Description"&lt;/SPAN&gt;
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
            
            &lt;SPAN style="color: blue;"&gt;'Recursively iterate child rows if present.&lt;/SPAN&gt;
            If Not oRow.ChildRows Is Nothing Then
                Call QueryBOMRowProperties(oRow.ChildRows, ItemTab)
            End If
        End If
    Next
    ItemTab = ItemTab - 3
End Sub&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 30 Aug 2019 09:40:31 GMT</pubDate>
    <dc:creator>ThomasB44</dc:creator>
    <dc:date>2019-08-30T09:40:31Z</dc:date>
    <item>
      <title>comment recuperer le niveau des enfants</title>
      <link>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/8990333#M5032</link>
      <description>&lt;P&gt;Bonjour,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;je souhaite recuperer le niveau de chaque enfant d'un fichier CAO Inventor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;malheuresement dans le referencedDodcument il y sont toutes mais je ne peux pas savoir le niveau de chacune.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;merci d'avance.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 14:59:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/8990333#M5032</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-27T14:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: comment recuperer le niveau des enfants</title>
      <link>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/8997359#M5033</link>
      <description>&lt;P&gt;Bonjour,&lt;/P&gt;
&lt;P&gt;Je pense qu'il faut utiliser la nomenclature ou la liste de pièces pour obtenir le niveau des enfants.&lt;/P&gt;
&lt;P&gt;Et exporter le repère pour connaitre le niveau.&lt;/P&gt;
&lt;P&gt;Ci-dessous un exemple de code qui manipule la nomenclature pour débuter tes recherches :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all"&gt;
&lt;DIV id="VBA" class="api-code ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-hidden="false" aria-labelledby="ui-id-1"&gt;
&lt;PRE class="api-code"&gt;Public Sub BOMQuery()
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the assembly document.&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' This assumes an assembly document is active.&lt;/SPAN&gt;
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    Dim FirstLevelOnly As Boolean
    If MsgBox("First level only?", vbYesNo) = vbYes Then
        FirstLevelOnly = True
    Else
        FirstLevelOnly = False
    End If
    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the BOM&lt;/SPAN&gt;
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    &lt;SPAN style="color: blue;"&gt;' Set whether first level only or all levels.&lt;/SPAN&gt;
    If FirstLevelOnly Then
        oBOM.StructuredViewFirstLevelOnly = True
    Else
        oBOM.StructuredViewFirstLevelOnly = False
    End If
    
    &lt;SPAN style="color: blue;"&gt;' Make sure that the structured view is enabled.&lt;/SPAN&gt;
    oBOM.StructuredViewEnabled = True
    
    &lt;SPAN style="color: blue;"&gt;'Set a reference to the "Structured" BOMView&lt;/SPAN&gt;
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
        
    Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description"
    Debug.Print "----------------------------------------------------------------------------------"

    &lt;SPAN style="color: blue;"&gt;'Initialize the tab for ItemNumber&lt;/SPAN&gt;
    Dim ItemTab As Long
    ItemTab = -3
    Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab)
End Sub

Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
    ItemTab = ItemTab + 3
    &lt;SPAN style="color: blue;"&gt;' Iterate through the contents of the BOM Rows.&lt;/SPAN&gt;
    Dim i As Long
    For i = 1 To oBOMRows.Count
        &lt;SPAN style="color: blue;"&gt;' Get the current row.&lt;/SPAN&gt;
        Dim oRow As BOMRow
        Set oRow = oBOMRows.Item(i)

        &lt;SPAN style="color: blue;"&gt;'Set a reference to the primary ComponentDefinition of the row&lt;/SPAN&gt;
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)

        Dim oPartNumProperty As Property
        Dim oDescripProperty As Property

        If Typeof oCompDef Is VirtualComponentDefinition Then
            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Part Number"&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'The file property is obtained from the virtual component definition&lt;/SPAN&gt;
            Set oPartNumProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Description"&lt;/SPAN&gt;
            Set oDescripProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
        Else
            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Part Number"&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'The file property is obtained from the parent&lt;/SPAN&gt;
            &lt;SPAN style="color: blue;"&gt;'document of the associated ComponentDefinition.&lt;/SPAN&gt;
            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            &lt;SPAN style="color: blue;"&gt;'Get the file property that contains the "Description"&lt;/SPAN&gt;
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
            
            &lt;SPAN style="color: blue;"&gt;'Recursively iterate child rows if present.&lt;/SPAN&gt;
            If Not oRow.ChildRows Is Nothing Then
                Call QueryBOMRowProperties(oRow.ChildRows, ItemTab)
            End If
        End If
    Next
    ItemTab = ItemTab - 3
End Sub&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 30 Aug 2019 09:40:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/8997359#M5033</guid>
      <dc:creator>ThomasB44</dc:creator>
      <dc:date>2019-08-30T09:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: comment recuperer le niveau des enfants</title>
      <link>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/9010537#M5034</link>
      <description>&lt;P&gt;Bonjour @Anonymous&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Si une des réponses résout votre problème ou vous a permis de mieux le comprendre, voulez vous avoir l'amabilité de cliquer sur le bouton "Approuver la solution" &lt;STRONG&gt;en bas de la réponse qui apporte une solution&lt;/STRONG&gt;?&lt;/P&gt;
&lt;H3&gt;&lt;I&gt;Merci de ne pas accepter comme solution le message que vous êtes en train de lire.&lt;/I&gt;&lt;/H3&gt;</description>
      <pubDate>Fri, 06 Sep 2019 14:05:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-forum-francais/comment-recuperer-le-niveau-des-enfants/m-p/9010537#M5034</guid>
      <dc:creator>patrick.emin</dc:creator>
      <dc:date>2019-09-06T14:05:07Z</dc:date>
    </item>
  </channel>
</rss>

