6 Replies Latest reply on Jan 11, 2017 4:13 PM by Ben Manders

    Refresh Configuration Properties

    Ben Manders

      I am working on doing some work updating properties and am unable to determine a way to refresh the UI so that the changes I make display right away.  For the below example, I change the configuration name to "NumberABC" and the configuration description to "DescriptionABC".  The display for the number updates immediately however the description doesn't show until I cycle back and forth to the design tree tab.  I've tried using EnableGraphicsUpdate, GraphicsRedraw2, and ForceRebuildAll without noticing a change in behavior.  I also have a similar problem when updating the custom properties of the configuration.

       

      Public Sub mainTest()

       

          Dim sValOut As String

          Dim sResolvedValOut As String

       

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swConfig = swModel.GetActiveConfiguration

          Set swModelView = swModel.ActiveView

       

          'swModelView.EnableGraphicsUpdate = False

       

          'Configuration Properties

          swConfig.Name = "NumberABC" 'Number

          swConfig.Description = "DescriptionABC"

       

       

          'swModelView.EnableGraphicsUpdate = True

          'swModel.GraphicsRedraw2

          'swModel.Rebuild (swForceRebuildAll)

       

      End Sub

        • Re: Refresh Configuration Properties
          Artem Taturevych

          You can use the trick below to refresh the tree

          swModel.ConfigurationManager.EnableConfigurationTree = False

          swModel.ConfigurationManager.EnableConfigurationTree = True

            • Re: Refresh Configuration Properties
              Ben Manders

              Works perfect - thanks Artem.

               

              Any suggestions how to do the same thing programmatically with the "Custom Properties" palette?  I can manually click on "More Properties" to bring up "Summary Information" and then click "OK" to close it and it refreshes properly.

                • Re: Refresh Configuration Properties
                  Ben Manders

                  I was able to get a majority of the properties to refresh by using swModel.ForceRebuild3 (False) however cannot get "Designed By", "Detailed By", and "Drawn Date" to refresh programmatically.

                   

                  Public Sub main()

                   

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      Set swCustomPrpMgr = swModel.Extension.CustomPropertyManager("")

                      Set swConfig = swModel.GetActiveConfiguration

                      Set swCustomPrpMgrConfig = swConfig.CustomPropertyManager

                      Set swModelView = swModel.ActiveView

                   

                      'swModelView.EnableGraphicsUpdate = False

                   

                      'File custom properties

                      swCustomPrpMgr.Add3 "Number", swCustomInfoText, "012345", swCustomPropertyReplaceValue  'Number

                      swCustomPrpMgr.Add3 "Description", swCustomInfoText, "descrip,one,text", swCustomPropertyReplaceValue  'Description1

                      swCustomPrpMgr.Add3 "Description2", swCustomInfoText, "descrip,two,other text", swCustomPropertyReplaceValue  'Description2  'Description2

                      swCustomPrpMgr.Add3 "Project", swCustomInfoText, "CASEPACKER BRM CONCEPTS", swCustomPropertyReplaceValue  'Project

                      swCustomPrpMgr.Add3 "Material", swCustomInfoText, "999999", swCustomPropertyReplaceValue  'Material **links to actual selection...

                      swCustomPrpMgr.Add3 "DrawnBy", swCustomInfoText, "B.Drawer", swCustomPropertyReplaceValue  'DrawnBy

                      swCustomPrpMgr.Add3 "DetailedBy", swCustomInfoText, "B.Detailer", swCustomPropertyReplaceValue  'DetailedBy

                      swCustomPrpMgr.Add3 "DrawnDate", swCustomInfoDate, "06/07/08", swCustomPropertyReplaceValue  'DrawnDate

                        

                      'Config specific custom properties

                      swCustomPrpMgrConfig.Add3 "Description", swCustomInfoText, "descrip,one,textAB", swCustomPropertyReplaceValue   'Description1

                      swCustomPrpMgrConfig.Add3 "Description2", swCustomInfoText, "descrip,two,other textAB", swCustomPropertyReplaceValue  'Description2

                      swCustomPrpMgrConfig.Add3 "DrawnBy", swCustomInfoText, "B.DrawerAB", swCustomPropertyReplaceValue  'DrawnBy

                      swCustomPrpMgrConfig.Add3 "DetailedBy", swCustomInfoText, "B.DetailerAB", swCustomPropertyReplaceValue  'DetailedBy

                      swCustomPrpMgrConfig.Add3 "DrawnDate", swCustomInfoDate, "06/07/08", swCustomPropertyReplaceValue     'DrawnDate

                      swCustomPrpMgrConfig.Add3 "Thickness", swCustomInfoText, "0.99", swCustomPropertyReplaceValue 'Thickness

                      swCustomPrpMgrConfig.Add3 "Width", swCustomInfoText, "1.99", swCustomPropertyReplaceValue 'Width

                      swCustomPrpMgrConfig.Add3 "Diameter", swCustomInfoText, "2.99", swCustomPropertyReplaceValue 'Diameter

                      swCustomPrpMgrConfig.Add3 "Length", swCustomInfoText, "3.99", swCustomPropertyReplaceValue 'Length

                      swCustomPrpMgrConfig.Add3 "Material", swCustomInfoText, "AAAAAA", swCustomPropertyReplaceValue 'Material **links to actual selection...

                      swCustomPrpMgrConfig.Add3 "Matnumber", swCustomInfoText, "BBBBBB", swCustomPropertyReplaceValue 'MaterialCode

                      swCustomPrpMgrConfig.Add3 "RAWMATERIAL", swCustomInfoText, "CCCCCC", swCustomPropertyReplaceValue 'RawMaterial

                    

                      'Configuration Properties

                      swConfig.Name = "Number" 'Number

                      swConfig.Description = "DescriptionABC"

                    

                      'swModelView.EnableGraphicsUpdate = True

                      'swModel.GraphicsRedraw2

                      'swModel.Rebuild (swForceRebuildAll)

                      swModel.ConfigurationManager.EnableConfigurationTree = False

                      swModel.ConfigurationManager.EnableConfigurationTree = True

                    

                      swModel.ForceRebuild3 (False)

                        

                  End Sub

                    • Re: Refresh Configuration Properties
                      Elmar Klammer

                      Try to toggle the custom property tab...I think that will update your values

                       

                      see code below

                       

                       

                      Sub main()
                      Set swApp = Application.SldWorks
                      swApp.ActivateTaskPane swTaskPaneTab_e.swDesignLibrary

                      'Change properties

                      swApp.ActivateTaskPane swTaskPaneTab_e.swCustomProps

                      End Sub
                      'swClipBoard 4 = Clipboard tab
                      'swCustomProps 5 = Custom Properties tab
                      'swDesignLibrary 1 = Design Library tab
                      'swFileExplorer 2 = File Explorer tab
                      'swPnID 6 = P&ID tab
                      'swResources 3 = SOLIDWORKS Resources tab

                      'swApp.ActivateTaskPane swTaskPaneTab_e.swCustomProps

                      end sub

                        • Re: Refresh Configuration Properties
                          Ben Manders

                          Elmar - thanks, that works.  Is there a way to tell what the state of the Task Pane is before I cycle it so I can return it to it's original state afterwards?  If the user doesn't have the task pane selected when they run the macro, I'd like it to return to that state once the macro is done.

                            • Re: Refresh Configuration Properties
                              Ben Manders

                              I figured something out that will work.  It cycles the visibility on the whole side toolbar.  I could query the original state of the palettes and return it but I decided that returning it all closed is best for my situation.

                               

                              wModelView.EnableGraphicsUpdate = False

                              swModel.SetToolbarVisibility swToolbar_e.swTaskPaneToolbar, False

                              'code

                              'code

                              swModel.SetToolbarVisibility swToolbar_e.swTaskPaneToolbar, True

                              swModelView.EnableGraphicsUpdate = True