<?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: Extracting a BoM using the Vault API in Vault Customization Forum</title>
    <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11862392#M2106</link>
    <description>&lt;P&gt;Well, that's a tricky answer. So, the reason I'm using code to create the items is because we have AutoCAD Electrical schematics that are attached to the Inventor files and to each other. Vault out-of-the-box Item creation does not recognize file attachments. So, I'm basically using the code to create the parent item and then iterating through the Vault file attachments to create the associated item and add it to the parent items BOM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works for Inventor files with DWG attachments.&lt;/P&gt;&lt;P&gt;It works for DWG files with DWG attachment where the child DWG is not attached to an AutoCAD Electrical project file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it tries to create a DWG item where the DWG is attached to the WDP file, even with stepping through the code and it's clearly promoting just a single DWG file, it tries to promote the attached WDP file instead and causing lots of errors and issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm not sure why the API is different when promoting a DWG with an attached WDP. I'm trying to find a workaround to accommodate it if I can't figure out the root cause.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2023 12:21:58 GMT</pubDate>
    <dc:creator>ThomasRambach</dc:creator>
    <dc:date>2023-03-31T12:21:58Z</dc:date>
    <item>
      <title>Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11554068#M2100</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to export a BoM from Vault using the API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially I found the function 'WebServiceManager.DocumentService.GetBOMByFileId', believing that I had hit the jackpot.&amp;nbsp; I then discovered, as discussed in some other forum posts, that this is just a template which the Item Master uses when it creates a BoM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then went down the road of extracting a BoM through the Item Master (ItemService.GetItemBOMByItemIdAndDate).&amp;nbsp; This seems to work great but the major problem is that you can only export a BoM for an Inventor assembly file if that assembly file already has items created for its entire BoM structure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did attempt to add in some logic which creates the items, if the items do not already exist, before extracting the BoM.&amp;nbsp; This method seemed to run into errors very frequently, which I believe was due to items getting locked, so I eventually gave up.&amp;nbsp; All my code is in the attached word document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anybody else been down this road?&amp;nbsp; If so, what direction did you go in the end?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, our system relies on using the Job Queue to open a session of Inventor and output the BoM to a CSV file.&amp;nbsp; I just find it very frustrating that all the data I need is sat within Vault, I just can't figure out how to extract it in a reliable way.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 16:47:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11554068#M2100</guid>
      <dc:creator>waynehelley</dc:creator>
      <dc:date>2022-11-15T16:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11558913#M2101</link>
      <description>&lt;P&gt;Your approach to promoting files to items is the right one, but your option ItemAssignAll.Default might cause duplicates and item locks. The code below is not "production" ready but should provide a foundation to start over.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;void m_AssignUpdateItem(object sender, long mFileId)
        {
            IWebService service = sender as IWebService;
            if (service == null)
                return;
            WebServiceCredentials cred = new WebServiceCredentials(service);
            using (WebServiceManager serviceManager = new WebServiceManager(cred))
            {
                long currentUserId = serviceManager.SecurityService.SecurityHeader.UserId;
                ItemService mItemSvc = serviceManager.ItemService;
                
                ItemsAndFiles promoteResult = null;
                Item[] updatedItems = null;
                bool m_PromoteFailed = false;
                try
                {
                    // in this case - we enforce to create/update an item by checkin; with that we must not cause the item creation "twice" in case an assembly's subcomponent also requires an item creation
                    // with that we have to set ItemAssignAll = No
                    mItemSvc.AddFilesToPromote(new long[] { mFileId }, ItemAssignAll.No, true);
                    DateTime timestamp;
                    GetPromoteOrderResults promoteOrderResults = mItemSvc.GetPromoteComponentOrder(out timestamp);
                    if (promoteOrderResults.PrimaryArray != null &amp;amp;&amp;amp; promoteOrderResults.PrimaryArray.Any())
                        try
                        {
                            mItemSvc.PromoteComponents(timestamp, promoteOrderResults.PrimaryArray);
                        }
                        catch
                        {
                            m_PromoteFailed = true;
                            //create new restriction / message 
                        }
                    if (promoteOrderResults.NonPrimaryArray != null &amp;amp;&amp;amp; promoteOrderResults.NonPrimaryArray.Any())
                        try
                        {
                            mItemSvc.PromoteComponentLinks(promoteOrderResults.NonPrimaryArray);
                        }
                        catch
                        {
                            m_PromoteFailed = true;
                            //create new restriction / message indicating that the item (unknown number here) linked to file e is probably locked by an editor
                        }
                    try
                    {
                        if (m_PromoteFailed != true)
                        {
                            promoteResult = mItemSvc.GetPromoteComponentsResults(timestamp);
                            //check the result for locked root item as we continue to update this
                            if (promoteResult.ItemRevArray[0].Locked != true)
                            {
                                updatedItems = promoteResult.ItemRevArray;
                                Item m_CurrentItem = promoteResult.ItemRevArray[0];
                                Item[] m_ItemToUpdateCommit = new Item[1];
                                m_ItemToUpdateCommit[0] = m_CurrentItem;
                                // commit the changes for the root element only; the reason is as stated before for ItemAssignAll = No
                                mItemSvc.UpdateAndCommitItems(m_ItemToUpdateCommit);
                            }
                            else
                            {
                                //create a restriction for file e and item promoteResult.ItemRevArray[0] Number / Title
                            }
                        }

                    }
                    catch
                    {
                        //still an unhandled situation?
                    }
                }
                catch
                {
                    if (updatedItems != null &amp;amp;&amp;amp; updatedItems.Length &amp;gt; 0)
                    {
                        long[] itemIds = new long[updatedItems.Length];
                        for (int i = 0; i &amp;lt; updatedItems.Length; i++)
                        {
                            itemIds[i] = updatedItems[i].Id;
                        }
                        serviceManager.ItemService.UndoEditItems(itemIds);
                    }
                }
                finally
                {
                    if (promoteResult == null &amp;amp;&amp;amp; m_PromoteFailed != true)
                    {
                        // clear out the promoted item
                        serviceManager.ItemService.DeleteUnusedItemNumbers(new long[] { promoteResult.ItemRevArray[0].MasterId });
                        serviceManager.ItemService.UndoEditItems(new long[] { promoteResult.ItemRevArray[0].Id });
                    }
                }
            }
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 11:39:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11558913#M2101</guid>
      <dc:creator>Markus.Koechl</dc:creator>
      <dc:date>2022-11-17T11:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11569930#M2102</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/33301"&gt;@Markus.Koechl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still not quite friends with the Item Master but this logic is working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wayne&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 12:51:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11569930#M2102</guid>
      <dc:creator>wayne.helleyY67EK</dc:creator>
      <dc:date>2022-11-22T12:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11699050#M2103</link>
      <description>&lt;P&gt;I am lookup to pull bills from the vault without creating Items for all the components. Until upgrading to Vault 2022, I was getting good results using the un-document GetBomByFileID but now the file IDs in the saved bill don't match the file IDs in the vault.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 questions about the code sample you provided.&lt;/P&gt;&lt;P&gt;Does the code only create an Item for the top level assembly and none of the sub-assemblies and parts?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I get the bill from the top level assembly Item without using the&amp;nbsp;&lt;STRONG&gt;UpdateAndCommitItems step?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 15:01:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11699050#M2103</guid>
      <dc:creator>ron_m</dc:creator>
      <dc:date>2023-01-23T15:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11860028#M2104</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/33301"&gt;@Markus.Koechl&lt;/a&gt;&amp;nbsp; I'm seeing some weird differences with this code between Vault 2021 and Vault 2023. The code works perfectly when I'm itemizing an AutoCAD file. But when the "AddFilesToPromote" AutoCAD file is also attached to an AutoCAD Electrical project file, the&amp;nbsp;PromoteComponents function tries to promote the parent ACAD-E Project file and not the DWG file. It makes no sense to me. Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 16:27:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11860028#M2104</guid>
      <dc:creator>ThomasRambach</dc:creator>
      <dc:date>2023-03-30T16:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11862328#M2105</link>
      <description>Does the manual UI command match your findings?</description>
      <pubDate>Fri, 31 Mar 2023 11:57:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11862328#M2105</guid>
      <dc:creator>Markus.Koechl</dc:creator>
      <dc:date>2023-03-31T11:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11862392#M2106</link>
      <description>&lt;P&gt;Well, that's a tricky answer. So, the reason I'm using code to create the items is because we have AutoCAD Electrical schematics that are attached to the Inventor files and to each other. Vault out-of-the-box Item creation does not recognize file attachments. So, I'm basically using the code to create the parent item and then iterating through the Vault file attachments to create the associated item and add it to the parent items BOM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works for Inventor files with DWG attachments.&lt;/P&gt;&lt;P&gt;It works for DWG files with DWG attachment where the child DWG is not attached to an AutoCAD Electrical project file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When it tries to create a DWG item where the DWG is attached to the WDP file, even with stepping through the code and it's clearly promoting just a single DWG file, it tries to promote the attached WDP file instead and causing lots of errors and issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm not sure why the API is different when promoting a DWG with an attached WDP. I'm trying to find a workaround to accommodate it if I can't figure out the root cause.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 12:21:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/11862392#M2106</guid>
      <dc:creator>ThomasRambach</dc:creator>
      <dc:date>2023-03-31T12:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting a BoM using the Vault API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/13349517#M2107</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/33301"&gt;@Markus.Koechl&lt;/a&gt;,&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I have returned to investigating BOM extraction using the Vault API.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Instead of using the item master, I decided to try using 'WebServiceManager.DocumentService.GetBOMByFileId'.&amp;nbsp; This was working fantastic for me (large BOMs exporting in less that 1 minute) but I am finding that as the day goes on, the time to export is increasing drastically (up to 10 minutes), possibly due to people being busy working on our Vault server.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I currently loop over the BOM recursively and execute&amp;nbsp;GetBOMByFileId on every file (latest version) to ensure that I get the latest property data.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I was just wondering if you had any options on if this a better or worst method than pulling data from the Item Master?&amp;nbsp; The solution that we have been using, over the last few years, is to just open an Inventor/Apprentice session and extract a BOM from there.&amp;nbsp; I was hoping that the API might be significantly more efficient so I'm surprised that it's running slowly for me. Maybe I am doing something inefficient in my code.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please ignore.&amp;nbsp; I discovered that the performance hit was coming from having coolOrange powerJobs/Events loaded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 08:50:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/extracting-a-bom-using-the-vault-api/m-p/13349517#M2107</guid>
      <dc:creator>waynehelley</dc:creator>
      <dc:date>2025-03-04T08:50:35Z</dc:date>
    </item>
  </channel>
</rss>

