<?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: Get Parts List from Drawing using C# in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-parts-list-from-drawing-using-c/m-p/4988384#M124964</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VBA PartListQuery example that was converted to C# in this DevBlog post may help.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://modthemachine.typepad.com/my_weblog/2012/11/c-help-examples-for-drawing-annotations-part-two.html" target="_blank"&gt;http://modthemachine.typepad.com/my_weblog/2012/11/c-help-examples-for-drawing-annotations-part-two.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could&amp;nbsp;update it so it processes each sheet&amp;nbsp;in a for loop using&amp;nbsp;the Sheets collection of the DrawingDocument.&amp;nbsp;The sheet&amp;nbsp;has a PartsLists&amp;nbsp;property you could use to get each&amp;nbsp;partslist on the sheet.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Wayne&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2014 23:20:54 GMT</pubDate>
    <dc:creator>wayne.brill</dc:creator>
    <dc:date>2014-04-24T23:20:54Z</dc:date>
    <item>
      <title>Get Parts List from Drawing using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-parts-list-from-drawing-using-c/m-p/4968074#M124963</link>
      <description>&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to work with the inventor API, trying to export parts lists from .idw drawings for assemblies using C#. I looked through the documentation and found the 'Parts List Query' sample program in the Autodesk Inventor 2014 API Help document. This is in VBA and also only works on active drawing sheets. I want my program to take in a list of .idw files and output excel or csv files of the parts list. I would like this program to be in C# becuase I already have code in C# interfacing with the Vault. Could someone please point me in the direction of where to find the answer to this question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my C# code that is a modified version of 'AssemblyTree' that is included as a C# sample with the SDK. This allows the user to point to an .iam file and it outputs a .csv file of the files on which it depends. This is close to what I need, but many of our drawings have parts on the BOM that do not have files and some filenames are not the same as their part numbers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void BuildTree()
{
    try
    {

        Inventor.ApprenticeServerDocument objapprenticeServerDocument = objapprenticeServerApp.Open(txtFileName.Text);

         if (objapprenticeServerDocument == null)
         {
             MessageBox.Show("Unable to open the specified file", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
          }

          IEnumerator objoccsEnumerator = objapprenticeServerDocument.ComponentDefinition.Occurrences.GetEnumerator();

          string csv = "";

           Inventor.ComponentOccurrence objcompOccurrence;
           while (objoccsEnumerator.MoveNext())
           {
                objcompOccurrence = (Inventor.ComponentOccurrence)objoccsEnumerator.Current;
                csv += objcompOccurrence.Name + "\n";
            }

            File.WriteAllText(@"C:\test.csv", csv);
        }
        catch (Exception)
        {
           MessageBox.Show("Unable to open and get the assembly heirarchy of the specified file", "Invalid File", MessageBoxButtons.OK,  MessageBoxIcon.Exclamation);
        }
    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Apr 2014 15:41:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-parts-list-from-drawing-using-c/m-p/4968074#M124963</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-17T15:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get Parts List from Drawing using C#</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/get-parts-list-from-drawing-using-c/m-p/4988384#M124964</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VBA PartListQuery example that was converted to C# in this DevBlog post may help.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://modthemachine.typepad.com/my_weblog/2012/11/c-help-examples-for-drawing-annotations-part-two.html" target="_blank"&gt;http://modthemachine.typepad.com/my_weblog/2012/11/c-help-examples-for-drawing-annotations-part-two.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could&amp;nbsp;update it so it processes each sheet&amp;nbsp;in a for loop using&amp;nbsp;the Sheets collection of the DrawingDocument.&amp;nbsp;The sheet&amp;nbsp;has a PartsLists&amp;nbsp;property you could use to get each&amp;nbsp;partslist on the sheet.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Wayne&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 23:20:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/get-parts-list-from-drawing-using-c/m-p/4988384#M124964</guid>
      <dc:creator>wayne.brill</dc:creator>
      <dc:date>2014-04-24T23:20:54Z</dc:date>
    </item>
  </channel>
</rss>

