4 Replies Latest reply on Aug 11, 2013 9:28 PM by Jin Fui Chong

    How to save the animation in solidworks motion study using API?

    Jin Fui Chong

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swModelDocExt As SldWorks.ModelDocExtension

      Dim swMotionMgr As SwMotionStudy.MotionStudyManager

      Dim swMotionStudy1 As SwMotionStudy.MotionStudy

      Dim swMotionStudy2 As SwMotionStudy.MotionStudy

      Dim swMotionStudy3 As SwMotionStudy.MotionStudy

      Dim swSaveAVIData As SwMotionStudy.AVIParameter

      Dim boolstatus As Boolean

       

      Sub main()

       

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swModelDocExt = swModel.Extension

       

       

       

          Set swSaveAVIData = swMotionMgr.CreateAVIParameter()

          swSaveAVIData.FramePerSecond = 7.5

          swSaveAVIData.SaveEntireAnimation = True

          swSaveAVIData.OutputType = 1 ' Save as an .avi file

       

      End Sub

        • Re: How to save the animation in solidworks motion study using API?
          Artem Taturevych

          After you have created the AVIParameter object just call the MotionStudy::SaveToAVI and pass output file name and the AVIParameter object.

          ____________________________________________________

          Regards,

          Artem Taturevych, Application Engineer at Intercad (Australia)

           

          translationXpert – add-in to translate SolidWorks models

          myIntercad an integrated tool for SolidWorks Professionals

          LinkedIn SolidWorks API Education Group

            • Re: How to save the animation in solidworks motion study using API?
              Jin Fui Chong

              Hi Artem,

               

              what do you mean by AVIParameter object? Do you have any example? i have no idea about call the MotionStudy::SaveToAVI..

                • Re: How to save the animation in solidworks motion study using API?
                  Artem Taturevych

                  Hi Jin,

                   

                  Check this:

                   

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  Dim swModelDocExt As SldWorks.ModelDocExtension

                  Dim swMotionMgr As SwMotionStudy.MotionStudyManager

                  Dim swMotionStudy1 As SwMotionStudy.MotionStudy

                  Dim swMotionStudy2 As SwMotionStudy.MotionStudy

                  Dim swMotionStudy3 As SwMotionStudy.MotionStudy

                  Dim swSaveAVIData As SwMotionStudy.AVIParameter

                  Dim boolstatus As Boolean

                   

                  Sub main()

                   

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      Set swModelDocExt = swModel.Extension

                      Set swMotionMgr = swModelDocExt.GetMotionStudyManager()

                      Set swSaveAVIData = swMotionMgr.CreateAVIParameter()

                      swSaveAVIData.FramePerSecond = 7.5

                      swSaveAVIData.SaveEntireAnimation = True

                      swSaveAVIData.OutputType = 1 ' Save as an .avi file

                   

                      Set swMotionStudy1 = swMotionMgr.GetMotionStudy("Motion Study 1")

                      swMotionStudy1.SaveToAVI "C:\MyAnim.avi", swSaveAVIData

                   

                  End Sub

                    • Re: How to save the animation in solidworks motion study using API?
                      Jin Fui Chong

                      Hi Artem,

                       

                      Thanks for your reply. But my code is not working. Do you have any idea about this?

                       

                      ............................................................................................................................

                       

                      Dim swApp As SldWorks.SldWorks

                      Dim swModel As SldWorks.ModelDoc2

                      Dim swModelDocExt As SldWorks.ModelDocExtension

                      Dim swMotionMgr As SwMotionStudy.MotionStudyManager

                      Dim swMotionStudy1 As SwMotionStudy.MotionStudy

                      Dim swSaveAVIData As SwMotionStudy.AVIParameter

                      Dim boolstatus As Boolean

                       

                      Sub main()

                       

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      Set swModelDocExt = swModel.Extension

                      Set swMotionMgr = swModelDocExt.GetMotionStudyManager()

                      Set swSaveAVIData = swMotionMgr.CreateAVIParameter()

                      swSaveAVIData.FramePerSecond = 7.5

                      swSaveAVIData.SaveEntireAnimation = True

                      swSaveAVIData.OutputType = 1 ' Save as an .avi file

                       

                      Set swMotionStudy1 = swMotionMgr.GetMotionStudy("Motion Study 1")

                          swMotionStudy1.SaveToAVI "C:\MyAnim.avi", swSaveAVIData

                       

                       

                      End Sub