We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Python Script to save Total deformation and Stress in a specific location (image

    • pavankonchada123
      Subscriber

      When I am trying to record the macro for saving Total Deformation and Stress as images using image to file option, I found that script is same for both cases. But how to differentiate between Deformation and stress for automation

      image_settings = Ansys.Mechanical.Graphics.GraphicsImageExportSettings()
      image_settings.CurrentGraphicsDisplay = False
      image_settings.Resolution = GraphicsResolutionType.NormalResolution
      image_settings.Capture = GraphicsCaptureType.ImageAndLegend
      image_settings.Background = GraphicsBackgroundType.White
      image_settings.FontMagnification = 1
      Graphics.ExportImage(r"""D:\Projects\ES.png""", GraphicsImageExportFormat.PNG, image_settings)

    • pavankonchada123
      Subscriber

      I want to run this journal file to extract the images

      result1 = system1.GetContainer(ComponentName="Results")
      result1.Edit(Interactive=False)

      DSscript = open("D:scrt.py", "r")
      DSscriptcommand=DSscript.read()
      DSscript.close()
      result1.SendCommand(Language='Python', Command = DSscriptcommand)

    • pavankonchada123
      Subscriber

      I have used as this as scrt.py but images are not coming

       

      '''NOTE : All workflows will not be recorded, as recording is under development.'''
      solu=Model.Analyses[0].Solution
      Graphics.Camera.FocalPoint = Point([0.000000, 0.050126, 0.000000], 'm')
      Graphics.Camera.ViewVector = Vector3D(0.57735, 0.57735, 0.57735)
      Graphics.Camera.UpVector = Vector3D(0, 1, 0)
      Graphics.Camera.SceneHeight = Quantity(0.126253, 'm')
      Graphics.Camera.SceneWidth = Quantity(0.046775, 'm')

      image_settings = Ansys.Mechanical.Graphics.GraphicsImageExportSettings()
      image_settings.CurrentGraphicsDisplay = False
      image_settings.Resolution = GraphicsResolutionType.NormalResolution
      image_settings.Capture = GraphicsCaptureType.ImageAndLegend
      image_settings.Background = GraphicsBackgroundType.White
      image_settings.FontMagnification = 1

      totdef = solu.AddTotalDeformation()
      totdef.EvaluateAllResults()

      Graphics.ExportImage(r"""D:\Projects\TD.png""", GraphicsImageExportFormat.PNG, image_settings)
      equstress = solu.AddEquivalentStress()
      equstress.EvaluateAllResults()
      Graphics.ExportImage(r"""D:\Projects\ES.png""", GraphicsImageExportFormat.PNG, image_settings)
      #endregion

       

Viewing 2 reply threads
  • The topic ‘Python Script to save Total deformation and Stress in a specific location (image’ is closed to new replies.