3 Replies Latest reply on Jun 11, 2015 11:35 AM by Leon Wurr

    Insertion point based on the numbers of rows of a BOM

    Leon Wurr

      Hello,

       

           I'm trying to modify a MACRO that places notes on drawings.

           Currently the insertion point must be selected for the MACRO to run.

       

           I want to set the insertion point right above the Bill Of Materials, but I'm having difficulties defining it.

       

           Can somebody help?

           I need to find the BOM within the drawing and then count the number o rows on it.

        • Re: Insertion point based on the numbers of rows of a BOM
          Leon Wurr

          So it's much more complicated than I thought, I'm fiddling with Esoxrepublic's BOMtoClipboard MACRO but I can't get it to run, not even the original file.

          I tried to run it with SW 2014 SP0.0 and SW2012 too, but the macro appears not to run at all, I don't get any messages. I tried with SW standard sheets and standard BOM and with my custom ones...

           

          Would a kind soul test it to see if it is just my SW that isn't running this MACRO? (http://www.esoxrepublic.com/freeware/macros/BOMtoClipboard.swp )

           

          Thanks a lot!

          • Re: Insertion point based on the numbers of rows of a BOM
            Mark Schwandt

            Try adding:

             

            Dim PickPt as Variant

             

            remember that pickpt has an x, y, and z to it even though you are working on a 2d drawing.

             

             

            and changing

            PickPt = DRW.GetInsertionPoint

            • Re: Insertion point based on the numbers of rows of a BOM
              Leon Wurr

              Finally I had the time to finish this, in case anyone is interested:

               

              The code to get the number of rows of the BOM:

               

              Private Sub subBOMrows()
              
              On Error Resume Next
              
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swDraw = swModel
              Set swSheet = swDraw.GetCurrentSheet
              Set swFeat = swModel.FirstFeature
              
              
              BOMcount = 0
              
              
              Do While Not swFeat Is Nothing
                  Set swBomFeat = swFeat.GetSpecificFeature2
                  If Not swBomFeat Is Nothing Then
                      BOMcount = BOMcount + 1
                  End If
                  Set swFeat = swFeat.GetNextFeature
              Loop
              
              
              BOMcontent = swBomFeat.GetTableAnnotations
              Set swBomAno = BOMcontent(0)
              Set swTable = swBomAno
              
              BOMrows = swTable.RowCount
              
              Debug.Print "Number of rows: " & BOMrows
              
              End Sub
              
              
              
              
              
              
              

               

              And then to set the point right above the BOM:

               

              Private Sub definePoint()
              
              
              Global PickPt(3)    As Double
              Global coordY       As Double
              
              
              coordY = BOMrows * RowHeight + 0.034    '0.034 is the standard titleblock height
              
              
              PickPt(0) = coordX  'this is set according to the sheet size
              PickPt(1) = coordY
              PickPt(2) = 0
              
              
              End Sub