2 Replies Latest reply on Dec 9, 2015 5:06 AM by Hrituc Alexandru

    Create drawings for all configurations

    Hrituc Alexandru

      Hi,

      I found this macro CreateDrawingsForAllConfsCreateDrawingsForAllConfs.swp.zip write by Artem Taturevych....

      How can modify this macro to add sheets with each configuration in the same drawing?... For example: I have a part with 5 configs... for one of them i make first sheet in drawing... When run the macro , this add another 4 sheets (1 sheet per config)

        • Re: Create drawings for all configurations
          Hrituc Alexandru

          I added pages for each configuration... then i see this steps.... activate each sheet and process views with different config... until now, i fail..

          • Re: Create drawings for all configurations
            Hrituc Alexandru

            why always remain the same config on each page?

             

            Dim swApp As SldWorks.SldWorks

            Dim swModel As SldWorks.ModelDoc2

            Dim swDraw As SldWorks.DrawingDoc

            Dim j As Integer

             

             

            Sub main()

             

             

                Set swApp = Application.SldWorks

             

             

                Set swModel = swApp.ActiveDoc

               

                Set swDraw = swModel

                   

                Dim i As Integer

               

                Dim vConfs As Variant

               

                Dim swView As SldWorks.View

               

                Set swView = swDraw.GetFirstView().GetNextView

                Dim swRefModel As SldWorks.ModelDoc2

                Set swRefModel = swView.ReferencedDocument

               

                vSheets = swDraw.GetSheetNames

                 'For j = 1 To swDraw.GetSheetCount

                    'swDraw.ActivateSheet vSheets(j - 1)

                    'Set swSheet = swDraw.GetCurrentSheet

             

             

                vConfs = swRefModel.GetConfigurationNames

                For i = 0 To UBound(vConfs)

                    Dim confName As String

                    confName = vConfs(i)

                    Debug.Print confName

                   

                    ProcessViews confName

                   

                   

                      swDraw.ActivateSheet vSheets(i)

                      Set swSheet = swDraw.GetCurrentSheet

                   

                    swModel.ForceRebuild3 True

                    'swModel.Extension.SaveAs OUTPUT_FOLDER + swModel.GetTitle() + "_" + confName + ".slddrw", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Copy, Nothing, 0, 0

                Debug.Print "conf2="; confName

                Next

               

            'Exit For

               ' Next j

               

                MsgBox "Completed"

               

            End Sub

             

             

            Sub ProcessViews(confName As String)

               

                Dim i As Integer

             

             

                Dim vSheets As Variant

                vSheets = swDraw.GetViews

             

             

                For i = 0 To UBound(vSheets)

                   

                    Dim j As Integer

                    Dim vViews As Variant

                   

                    vViews = vSheets(i)

                   

                    For j = 0 To UBound(vViews)

                        Dim swView As SldWorks.View

                        Set swView = vViews(j)

                        swView.ReferencedConfiguration = confName

                    Next

                   

                Next

               

            End Sub