9 Replies Latest reply on Apr 26, 2016 4:02 AM by Viktor Bovzdarenko

    Update Table Macro Help

    Nick Grisco

      I currently use SW2015 have been using this macro since probably around 2006. This macro is used to open and update the design tables for some custom properties to update and display the correct information in the BOM. It still works fine for smaller assemblies, but larger assemblies are crashing SW. The problem seems to be the GDI limit. As soon as I see it hit 10000 GDI objects in task manager, SW crashes. I've tried increasing the GDI limits in the registry, but it still crashes at 10000. So I'm wondering if there is a more efficient way of running this macro or if there are new programming commands that would work better since this macro was created so long ago. I want the macro to find every part that has a design table in the current assembly, update the design table and close the part. The current macro does not seem to be completely closing the part since the GDI count keeps rising while the macro is running. I don't have much experience with programming macros, so any help would greatly appreciated! Thanks!



        • Re: Update Table Macro Help
          Viktor Bovzdarenko

          Hi Nick

          This is a known issue and each time when the document is loaded in SolidWorks it takes some GDI and does not release it after closing the document. As a solution you can try a few things: 1st. do not open each part in the assembly since all parts are already loaded. This should use less GDI and prevent SolidWOrks crashing.  I tried your macro and it still returns TRUE on update. Make sure that assembly is fully loaded (no in big assembly mode or lightweight)


          While NumDocsReturned <> 0

              Set swDocXt = swDoc.Extension

              If swDocXt.HasDesignTable Then

                  DesTblCount = DesTblCount + 1

                  bDocWasVisible = swDoc.Visible

          '        swApp.ActivateDoc swDoc.GetPathName

                  Set DesTbl = swDoc.GetDesignTable

                  dummy = DesTbl.Attach

                  dummy = DesTbl.UpdateTable(swDesignTableUpdateOptions_e.swUpdateDesignTableAll, True)


                  swDoc.Visible = bDocWasVisible

              End If

              swAllDocs.Next 1, swDoc, NumDocsReturned

              DocCount = DocCount + 1


          'swApp.ActivateDoc FirstDoc.GetPathName

          Set swApp = Application.SldWorks

          End Sub


          Another solution is to create an independent stand alone application which would restart solidworks and continue running your macro after  GDI riches some limit. At the moment your macro cannot launch solidworks session and pass parameters there since macro itself will be closed with first Solidworks session.


          Hope this helps