3 Replies Latest reply on Jun 4, 2012 9:49 AM by Jason Swackhamer

    Sheet Number in BOM

    James Cliff

      Hi all,


      Repost.... in the correct category this time.

      I have recently decided to begin compiling all my component and assembly drawings into one file instead of individual files. It may take slightly longer to save and load but in the long run I find its much much easier and cleaner to manage. Obviously I have a schedualed backup to USB HDD twice a day to help eliminate the risk of loosing my work.


      Anyway, to the point..... I arrange my drawings with an isometric view of the complete assembly as the first page, with baloons and subsequent BOM. Previously I have gone through and added page numbers to each drawing (When using individual drawings) and then manually added the corrosponding page number to the part row in the BOM. As my latest project will consist of 150+ part drawings this will be a horrificly labour intensive process! Time I just havent got.


      Considering I am now using one file with multiple sheets to house all my drawings, is there any way to add the sheet number for each part drawing to the corrosponding part in the BOM for that part assembly drawing? I presume this could be done using a macro and a for loop to carry out the following sequence:


      1. Add additional column to BOM


      Loop for each BOM Row:


      1. Save DWG NO bom value (Custom property assigned in part model) to a variable

      2. Find corrosponding sheet name (My sheet names are the DWG NO) in document

      3. Save the page no for that sheet into variable.

      4. Add this saved variable into the corrosponding row for that part in the BOM.

      5. Move onto the next row.

      6. Stop once complete.


      Am I along the right sort of track here?

      I have done a small amount of VBA before, but have no clue about the solidworks code side of things.

      I would be greatful if someone could point me in the right direction with this.


      Many thanks,


        • Re: Sheet Number in BOM
          Keith Rice



          This can certainly be done.  If you are looking for introductory SolidWorks API materials, I have over 3 hours of free videos at my web site, Video Tutorials for the SolidWorks API.  Lesson 6.1 would be very helpful to you as well, should you decide to go premium.


          Otherwise, to get started, you might check out the free macro I have in the Macro Library called "Get cell data in active sheet's table".  This will at least show you how to work with the ITableAnnotation interface, which you'll need to use when you working your BOM.


          Anyway, your steps seem OK.  So your first page is the full assembly and each subsequent page is an individual part?  And each part has a custom property called DWG NO, and you're going to get that value and put it in the appropriate row in the BOM?



            • Re: Sheet Number in BOM
              James Cliff

              Just signed up to the site Keith, although I'm going to struggle to become a premium member just yet. I will do some research though.

              Your right yes, the first page is the full assembly featuring each sub assembly, of which each has a unique DWG NO and subsequently sheet number. Then throughout the multisheet drawing is each sub assembly containing its own BOM and components. Every part and assembly has a unique DWG NO in a custom property specified when modelled.


              I need to write a macro that works through each BOM on every assembly drawing finding the corrosponding sheet number for that DWG NO and adding it to the BOM row. Its alot of work to create this, but in the long run it will save me many hours!




            • Re: Sheet Number in BOM
              Jason Swackhamer



              One possible change to your scheme--instead of adding the sheet number to the bill of materials as a direct edit, why not add the sheet number as a custom property to the part? Then include that property in a column in the bill of material. This will keep the sheet number associated to the correct line in the bill of material whatever the ordering. This is basically how we do it.


              I realize that this won't work so well if you reference a part file in multilple drawing sets.


              -Jason S.