18 Replies Latest reply on Jul 1, 2014 4:06 PM by Jorn Bjarning

    Macro/application performance

    Jorn Bjarning

      Hi everybody,


      Long time ago I made a VBA macro which included a feature traversal routine for parts. Worked perfect. Recently I upgraded this macro to VB .Net 2013. Still works perfect in terms of functionality but the performance is terrible.


      In order to verify/prove the situation I have simplified the macro to a very simple feature traversal routine like shown below (.net version). The main part of the program is not included here.


      For a random model of mine it takes: 

      0,00348 sekunder - with the old VBA macro

      7,24 sekunder - with Visual Studio 2013


      Can anyone explain why? Am I missing some important setting in Visual Studio which can explain this factor 2000 difference?



      Sub TraverseFeatures(ByVal swModel As ModelDoc2)


              Dim swFeat As Feature
              Dim swSubFeat As Feature
              Dim sFeatureName As String
              Dim sSubFeatureName As String


              'Get first feature
              swFeat = swModel.FirstFeature

              sFeatureName = ""


              'Loop through all features       

              Do While Not swFeat Is Nothing

                  sFeatureName = swFeat.Name

                  'Get first sub feature
                  swSubFeat = swFeat.GetFirstSubFeature


                  'Loop through all subfeatures until cut-list folder is found - if present
                  Do While Not swSubFeat Is Nothing


                      'Get subfeature name
                      sSubFeatureName = swSubFeat.Name


                      'Get next sub feature
                      swSubFeat = swSubFeat.GetNextSubFeature


                  'Get next feature
                  swFeat = swFeat.GetNextFeature



      End Sub