0 Replies Latest reply on Jun 18, 2018 3:28 PM by Colt Carson

    Unable to output tga file while saving animation using api.

    Colt Carson

      I am having trouble getting the SaveToAVI method to output a series of tga files from an animation. I cobbled together a macro that works just fine when outputting avi and bmp file types but does not create any files when when using the tga output option. Strangely, the return value from SaveToAVI is true so solidworks thinks it has succeeded. Could someone tell me what I am doing wrong? Attached is a sample assembly.

       

      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 sConfigName As String

      Dim swConfig As SldWorks.Configuration

      Dim Scene As SldWorks.SWScene

       

       

       

      Sub main()

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set swModelDocExt = swModel.Extension

          Set swMotionMgr = swModelDocExt.GetMotionStudyManager()

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

          Set swConfig = swModel.GetActiveConfiguration

          Set Scene = swConfig.GetScene

       

          result = Scene.DeleteFloorAppearance()

          Scene.FloorReflections = False

          Scene.FloorShadows = False

         

          sConfigName = swModel.GetActiveConfiguration.Name

          Dim fn As String

         

          'fn = "C:\test\" & sConfigName & ".avi"  'this works

          'fn = "C:\test\" & sConfigName & ".bmp"  'this works

          fn = "C:\test\" & sConfigName & ".tga" 'this doesn't

       

         

          swMotionStudy1.PlayMode = swAnimationPlayMode_e.swAnimationPlayModeNormal

          swMotionStudy1.SetTime (0)

          swMotionStudy1.SetDuration (10)

          swMotionStudy1.Calculate

         

          Set swSaveAVIData = swMotionMgr.CreateAVIParameter()

          swSaveAVIData.PreserveRatio = False

          swSaveAVIData.ImageSize = swSaveAVIImageSize_e.swImage_Custom

          swSaveAVIData.ScreenWidth = 1000

          swSaveAVIData.ScreenHeight = 1000

          swSaveAVIData.FramePerSecond = 1

          swSaveAVIData.SaveEntireAnimation = True

          

          'swSaveAVIData.OutputType = swAnimationOutputType_e.swAnimationOutput_AVI 'this works

          'swSaveAVIData.OutputType = swAnimationOutputType_e.swAnimationOutput_Series_of_BMP 'this works

          swSaveAVIData.OutputType = swAnimationOutputType_e.swAnimationOutput_Series_of_TGA 'this doesn't

         

          swSaveAVIData.RendererType = swRendererType_e.swRendererType_Solidworks_Screen

          swMotionStudy1.Stop

       

          result = swMotionStudy1.SaveToAVI(fn, swSaveAVIData)

          Debug.Print (result)  ' result is true even though no files were created

      End Sub