2 Replies Latest reply on Nov 28, 2018 7:59 AM by Chris Griffith

    Disable graphics update

    Chris Griffith

      I have written a macro that will open a form where the user can input a size and length of a part and the macro checks to see if that configuration exists in a part file.  If it does not exist it opens the part file, updates the design table, closes the file, and then changes the selected part to the new configuration.  This all works great but I would like to make it so that it doesn't show any of these actions on the screen, in the hopes that it speeds it up a little bit.  So all the user would see is the selected part change to the new configuration.  I've tried a few different things but nothing seems to work.  Any suggestions?  I can provide my code and files if that would help.  Right now the code is a little rough and doesn't have much for error checking but it is doing what I want.  Thanks

        • Re: Disable graphics update
          Artem Taturevych

          Hi Chris,


          You can look at this example which demonstrates how to suspend all the graphics updates (including opening of new documents): Suspend Graphics Update



            • Re: Disable graphics update
              Chris Griffith

              I have one subroutine that opens a part file, inserts it into the assembly, closes the part, changes it to virtual in the assembly, and then renames it.  The code you gave me works perfectly for that.


              However I have another subroutine that then opens that virtual file, updates the design table, and then closes it.  I don't know if it's because it's a virtual file but most of the time the OpenDoc6 doesn't work on this file, I'm assuming because it's already technically open because it's virtual.  So I have put a catch in that if the file that is open does not equal the virtual file path then it activates the virtual file and that always works.  However I don't think the code you provided suppresses updates when activating a document rather than opening a document.  Any advice on how I would do this?  The code for that subroutine is shown below.  


              'Opens HSS file and updates design table with new configuration

              Sub UpdateHSSDesignTable()


                      Set swApp = Application.SldWorks


                      On Error GoTo End_



                      If SUPPRESS_UPDATES Then

                          SuppressUpdates swModel, True

                      End If


                      Set swModel = swApp.OpenDoc6(oFile, swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning)

                      Set swModel = swApp.ActiveDoc


                      If swModel.GetPathName <> oFile Then

                          Set swModel = swApp.ActivateDoc2(oFile, False, fileerror)

                      End If


                      Set swDesignTable = swModel.GetDesignTable()


                      ' Name of configuration for newly created row

                      cells(0) = HSSConfig

                      ' Data for new configuration

                      cells(1) = DimWidth

                      cells(2) = DimHeight

                      cells(3) = DimWall

                      cells(4) = DimLength

                      cells(5) = MaterialDesc


                      boolstatus = swDesignTable.AddRow((cells))

                      boolstatus = swDesignTable.UpdateTable(SwConst.swDesignTableUpdateOptions_e.swUpdateDesignTableAll, True)



                      swApp.CloseDoc (oFile)


              End_:                         'restore the flag otherwise all files will be opened invisible


                      If SUPPRESS_UPDATES Then

                          SuppressUpdates swModel, False

                      End If


                      NewConfig = HSSConfig

              End Sub