4 Replies Latest reply on Jun 12, 2015 9:48 AM by Hrituc Alexandru

    Macro to make drawings for flat pattern configurations

    Hrituc Alexandru

      Hi everyone,

       

      1. How can modify this macro to make drawings only for flat pattern configurations??..

      2.How can modify to save drawings with name of part, not with title of drawing?

       

                     Thank you,

        • Re: Macro to make drawings for flat pattern configurations
          Adam Hoffman

          Try the attached macro. Before running it, you must have a drawing open that you want to use as a template. It will save the drawings in the same folder as the sheet metal part. If you have a predetermined folder that you want to save the drawings instead, then we can get it fixed for you simple enough. Hope this helps.

            • Re: Macro to make drawings for flat pattern configurations
              Hrituc Alexandru

              HI ADAM,

               

              I apologize that I was not more explicit in first post.

              Is going well but the original file (10.8 K) is closer to what I need because as you can see in the picture the text is linked to view and the macro change one by one all config and save in the predetermined folder.

              1.jpg

              I modify the macro to save also in dxf, but gather several files I do not need and from here the desire to do drawings just for flat pattern configs..

               

              Const OUTPUT_FOLDER = "C:\Users\alexandru.hrituc\Desktop\Automatic Drawings\"

               

               

              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim swDraw As SldWorks.DrawingDoc

               

               

              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

                

                  vConfs = swRefModel.GetConfigurationNames

                

                  For i = 0 To UBound(vConfs)

                

                      Dim confName As String

                      confName = vConfs(i)

                      ProcessViews confName

                      swModel.ForceRebuild3 True

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

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

                  Next

               

               

                  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