1 Reply Latest reply on Jan 16, 2013 5:34 PM by Bryce Hooper

    GetDerivedBOMs Question

    Jim Sculley

      I'm working on a simple little add-in that will allow users to right click a drawing or assembly file and print a BOM from it. 


      Since the order of a computed BOM has no relationship to the order of the parts in the assembly,  I am using derived BOMs based on the Bill of Material in the drawing so that everything stays synchronized if the model is changed.  There are no named BOMs being used.


      I have noticed that in this scenario, GetDerivedBOMs will return a distinct BOM (unique ID) for each version of the underlying SolidWorks file.  If I call GetObject on any of the BOM IDs of these derived BOMs to retrieve the IEdmBom from the vault, the resulting object is a BOM with a single version (checked by calling GetVersions()) corresponding to an underlying version of the drawing file.


      It seems odd that a single drawing file with multiple versions leads to multiple BOMs with a single version each.


      In order to make sure that I get the lastest version of the BOM for printing, I am forced to assume that the highest document ID is the most recent version.  The timestamps cannot be used because there may be a delay between the drawing versionand the BOM version.  This is all quite kludgy, and I'd rather have something more robust.


      Have I missed something or is this my only option?


      Jim S.

        • Re: GetDerivedBOMs Question
          Bryce Hooper

          I realize this is likely long dead.  But I was searching for a solution to this problem and came up with one myself...


          The solution is that the array of IEdmBom you recieve from a GetDerivedBOMs() function each has its ID in it.  It lacks the rest of the important information to determine if it belongs to the current version of the drawing.  The information is still available... however you must query it from the SQL.  To find the version that the table belongs to, query dbo.BomSheets for 'SourceDocumentVersion' using the bom's 'ID' as a parameter.  To ensure that this version number matches what is most current in the vault you can do another query for a value to compare again.  Query dbo.Documents for "LatestRevisionNo" using "FileID" as a parameter.  Comparing these 2 values gives you the knowledge of if it is current or not.