Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
21 changes: 15 additions & 6 deletions 2026R1/motion_post_lib_doc-26-r1/changelog_operation_api.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Operation API

## Common setting
Import the OperationAPI.py file from the "Ansys installed path/Motion/Document/Postprocessor API for Python.zip" file.
## Common Settings

## Added
- Support for reading RPC file formats has been added to the Import feature.
- Introduced fatigue durability analysis functionality.
- Added the **ResultName** property to the **DurabilityAnalysisParameter** class.
- Added the **ExportContourResultToFile** method to the **Export** class.
- Added functions to **IOperationsAnimation** that allow changing the state of entities to Fit, Hide, or Show.

## Changed
- The Following Camera has been changed.
- The UI for NumericImport has been changed.
- Changed the namespace from **VM.Post.API.Fatigue.Models** to **VM.Operation.Post**.
- Renamed **IOperationAnalysisResultViewModel** to **IOperationAnalysisResult**.
- Renamed **IOperationsFEBodyViewModel** to **IOperationsFEBody**.
- Renamed the **FilePath** property in the **DurabilityAnalysisParameter** class to **DocumentFilePath**. The **FilePath** property will be removed in the future.
- Renamed the **UpperValue** property in the **DurabilityAnalysisParameter** class to **End**. The **UpperValue** property will be removed in the future.
- Renamed the **LowValue** property in the **DurabilityAnalysisParameter** class to **Start**. The **LowValue** property will be removed in the future.
- Changed the result item name from **Max Principal** to **Max Abs Principal**.
- Changed the result item name from **Max Shear Stress** to **Max Shear**.

## Deprecated
- **ApplicationHandler.ImportNumeric()** is deprecated and will be removed soon; it is recommended to transition to **IOperationsChartViewModel.ImportNumeric()**.
- Removed the **VM.Post.API.Fatigue** DLL.
- The **FatigueParameter** class will be removed in the future. It will be replaced by a property in **FEBody**.
100 changes: 100 additions & 0 deletions 2026R1/motion_post_lib_doc-26-r1/example_Import_for_operation_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Example
The following sample code illustrates how to create a simple example.
* The examples provided below can be found within the 'Install_Path\Motion\Document\Postprocessor API for Python.zip' compressed file.

## Numeric Import
Here is an example of importing curve results from a file.
```python
# OperationAPI_NumericImport.py
import sys

# Get the current file's path and set the path for external modules.
current_dir = __file__.rsplit('\\', 1)[0]
external_modules_path = current_dir + '\\..\\..\\Modules'
sys.path.append(external_modules_path)

# Import necessary modules
from OperationAPI import *

# Start the headless application interface
applicationHandler = ApplicationHandler()

# Import result file
result_file_path = get_result_file_path()

# Set array about result file
filepaths = List[str]()
filepaths.Add(result_file_path)

# Open about result files
# This will open the result file in the application.
# When the result is first opened, a Page is created and an Animation View is created on that Page.
applicationHandler.AddDocument(filepaths)

# Get Active Page
# This retrieves the currently active page in the application.
page = applicationHandler.GetActivePage()

# Creating a Chart
# Create a new Chart View on the page
# This will create a new chart view with the specified name.
chartView = page.CreateChart("Chart")

# Set array about combination of characteristic and component
curvePaths = List[str]()
curvePaths.Add(r'Displacement/Magnitude')
curvePaths.Add(r'Displacement/Z')

# Create a PlotParameters object to specify the parameters for the plot.
# Set the Entity to Plot.
# The Target is the name of the target for which you want to retrieve the curves.
# Set the paths for the curves you want to retrieve.
# This is where you specify the characteristics and components you want to plot.
parameters = PlotParameters()
parameters.Paths = curvePaths
parameters.Target = "Crank"

# Add Curves (FilePath, Curve Parameter)
# FilePath - The path of the result to access.
# parameters - The class used as a parameter of the AddCurve function.
# The instance of the curve.
curves = chartView.AddCurves(result_file_path, parameters)

index = 0
for curve in curves :
curve.SeriesName = "NameChange_{0}".format(index)
index = index + 1

# File Dialog Open
# chart1.ExportAllDataSeries()

# use not file dialog
output_dir = get_output_directory()
file_path = combine_path(output_dir, r'curvedata.txt')
chartView.ExportAllCurves(export_filepath)

# Importing Numeric Data
parameters = List[INumericParameter](2)

# To create a curve from a file, create a NumericParameter.
# Name - The name of the curve to be created.
# TargetX - The name of the X-axis data.
# TargetY - The name of the Y-axis data.
# In this example, a curve named 'OrderTrackingCurve' is created, and data corresponding to the X and Y headers is retrieved from the file.
parameter = NumericParameter()
parameter.Name = r'NameChange_10'
parameter.TargetX = r'Time(sec)'
parameter.TargetY = r'NameChange_1'
parameters.Add(parameter)

# file_path - The path to the file containing the numeric data.
# parameters - The list of numeric parameters that define how to interpret the data in the file.
chartView.ImportNumeric(file_path, parameters)

# Close the Pages
page.Close()

# Close the Document
applicationHandler.CloseDocument(result_file_path)

```
184 changes: 181 additions & 3 deletions 2026R1/motion_post_lib_doc-26-r1/example_analysis_for_operation_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,172 @@
The following sample code illustrates how to create a simple example.
* The examples provided below can be found within the 'Install_Path\Motion\Document\Postprocessor API for Python.zip' compressed file.

## Fatigue Analysis
This example demonstrates Fatigue Analysis.
**The example assumes that the material has already been defined.** If you are running it for the first time, you need to create the material in advance.
```python
# DurabilityAnalysis.py
# -*- coding: utf-8 -*-
import sys

# Get the current file's path and set the path for external modules.
current_dir = __file__.rsplit('\\', 1)[0]
external_modules_path = current_dir + '\\..\\..\\Modules'
sys.path.append(external_modules_path)

# Import necessary modules
from OperationAPI import *

# Start the headless application interface
applicationHandler = ApplicationHandler()

# Import result file
result_file_path = get_result_file_path()

# Set array about result file
filepaths = List[str]()
filepaths.Add(result_file_path)

# Open about result files
# This will open the result file in the application.
# When the result is first opened, a Page is created and an Animation View is created on that Page.
applicationHandler.AddDocument(filepaths)

# Get Active Page
# This retrieves the currently active page in the application.
page = applicationHandler.GetActivePage()

# Get Active View
# This retrieves the currently active view in the page.
activeView = page.GetActiveView()

# Loading Animation - Use this only when the current Active View is an Animation View.
# This method is used to load the animation in the active view.
applicationHandler.LoadingAnimation()

# Get the FEBody instance
# The GetViewModelByName method retrieves the target by its name.
febody = activeView.GetViewModelByName("FEBody_01")

# Get the Material instance
# The GetViewModelByName method retrieves the material by its name.
material = activeView.GetViewModelByName("2014_HV_O")

# Check if the FEBody and Material are found
if febody is None or material is None:
sys.exit(1)

# Set the febody and material properties
febody.Material = material

# Set Analysis Type
# FatigueAnalysisType can be one of the following:
# - FatigueAnalysisType.SN - SN Curve
# - FatigueAnalysisType.EN - EN Curve
febody.AnalysisType = FatigueAnalysisType.SN

# Set Stress-Strain Combination
# StressStrainCombinationType can be one of the following:
# - StressStrainCombinationType.VonMises - VonMises
# - StressStrainCombinationType.Signed_VonMises - Signed VonMises
# - StressStrainCombinationType.Max_Principal - 1st Principal
# - StressStrainCombinationType.Min_Principal - 3rd Principal
# - StressStrainCombinationType.Max_ABS_Principal - Max Abs Principal
# - StressStrainCombinationType.Max_Shear - Max Shear
# - StressStrainCombinationType.Signed_Max_Shear - Signed Max Shear
# - StressStrainCombinationType.Average_Principal - Average Principal
febody.StressStrainCombination = StressStrainCombinationType.VonMises

# Set Mean Stress Correction
# - MeanStressCorrection.Neglect - Neglect
# - MeanStressCorrection.ModifiedGerber - Modified Gerber
# - MeanStressCorrection.GerberLocus - GerberLocus
# - MeanStressCorrection.Sodeberg - Sodeberg
# - MeanStressCorrection.DEelliptic - DEelliptic
febody.MeanStressCorrection = MeanStressCorrection.Neglect

# Fatigue analysis parameters
# DocumentFilePath - The path to the result file.
# ResultName - Name of the fatigue result. The result will be saved in the Fatigue folder under the result file directory.
# NoOfRepeatedLoad - Number of repeated loads
# Start - Start time
# End - End time
# AddTarget - Adds a target. The target value is the ID of the FEBody.
durabilityParameter = DurabilityAnalysisParameter()
durabilityParameter.DocumentFilePath = result_file_path
durabilityParameter.ResultName = "FEBbody_01_Fatigue"
durabilityParameter.NoOfRepeatedLoad = 1
durabilityParameter.Start = 1
durabilityParameter.End = 10
durabilityParameter.AddTarget(febody.ID)

# Run the fatigue analysis
DurabilityAnalysis.RunFatigueAnalysis(durabilityParameter)

# Run the fatigue analysis with contour
# DurabilityAnalysis.RunFatigueAnalysisAndGenerateContours(durabilityParameter)

# Output Path
life_cycle_path = combine_path(get_output_directory(), "Fatigue_Life_Cycle.txt")

# Set the febody fullname as the target for export
targetNames = List[str]()
targetNames.Add(febody.FullName)

# A boolean indicating whether to export the full frame or not.
# If True, the full frame will be exported; if False, only the current frame will be exported.
is_full_frame = True

# Set Contour Mapping Type
# ContourMappingType can be one of the following:
# - ContourMappingType.None - None
# - ContourMappingType.FENode - Node (Averaged across body)
# - ContourMappingType.FEElement - Element (Unaveraged)
# - ContourMappingType.FEElementNode - Node (Unaveraged)
# - ContourMappingType.FEMaterial - Node (Averaged within material)
# - ContourMappingType.BeamGroup - Beam Group
# - ContourMappingType.Contact - Contact
# - ContourMappingType.ChainedSystem - Chained System
# - ContourMappingType.Usersubroutine - Usersubroutine
contour_mapping_type = ContourMappingType.FEElement

# Set Characteristic Path
characteristic_path = "Fatigue"

# Set Component Path
component_path = "Life Cycle"

# Combine Characteristic and Component Path
characteristic_component_path = characteristic_path + "/" + component_path

# Set the fatigue path
# - DocumentFilePath: The path to the result file.
# - FatiguePath: The fatigue results are saved in the Fatigue folder under the result file directory. Specify the name of the result file inside this Fatigue folder.
DurabilityAnalysis.SetFatiguePath(result_file_path, "FEBbody_01_Fatigue")

# Export Contour Result to File
# result_file_path - The path to the result file.
# life_cycle_path - The path to the output file where the life cycle data will be saved.
# targetNames - The list of target names for which the contour results will be exported.
# is_full_frame - A boolean indicating whether to export the full frame or not.
# contour_mapping_type - The type of contour mapping to be used.
# characteristic_component_path - The path to the characteristic and component for which the contour results will be exported.
# AnalysisType - The default value is AnalysisResultType.Dynamics. If you want to change it, please set the AnalysisType.
# FileFormatType - The format of the output file. The default is FileFormatType.Text. The format type can be set to TXT or BINARY.
Export.ExportContourResultToFile(result_file_path, life_cycle_path, targetNames, is_full_frame, contour_mapping_type, characteristic_component_path)

# Close all open pages.
# Get all created pages.
# This retrieves all pages created in the application.
pages = applicationHandler.GetPages()
for page in pages :
page.Close()

# Close Document
applicationHandler.CloseDocument(result_file_path)

```

## Sound Pressure
Sound pressure analysis (SPA) can be used to analyze the sound pressure generated by the vibration of the system surface based on "Rayleigh Integral". this example describes how to create the Sound Pressure.
* Before the analysis, the bodies that are the source of sound pressure must be defined as FE or EasyFlex bodies in the preprocessor.
Expand All @@ -10,10 +176,12 @@ Sound pressure analysis (SPA) can be used to analyze the sound pressure generate
# OperationAPI_CreatingASoundPressure.py
import sys

# Get the current file's path and set the path for external modules.
current_dir = __file__.rsplit('\\', 1)[0]
external_modules_path = current_dir + '\\..\\..\\Modules'

sys.path.append(external_modules_path)

# Import necessary modules
from OperationAPI import *

# Start the headless application interface
Expand All @@ -27,9 +195,12 @@ filepaths = List[str]()
filepaths.Add(result_file_path)

# Open about result files
# This will open the result file in the application.
# When the result is first opened, a Page is created and an Animation View is created on that Page.
applicationHandler.AddDocument(filepaths)

# Find Page
# Get all created pages.
# This retrieves all pages created in the application.
pages = applicationHandler.GetPages()

findViews = list()
Expand All @@ -43,8 +214,14 @@ for page in pages :
viewCount = len(findViews)
if viewCount > 0 :
animationview = findViews[0]

# Create a Coordinate System
# Name - Set the name of instance.
# ParentInfo - Specifies The path of an parent entity.
animationview.CreateCoordinateSystem("Microphone", "Ground")

# Get instance of entity
# The GetViewModelByName method retrieves the target by its name.
microphone = animationview.GetViewModelByName("Microphone")
microphone.TransformationOffsetPosition = Vector(0,300,0)

Expand All @@ -67,7 +244,8 @@ if viewCount > 0 :
# isDeicbelScale - The decibel scale.</param>
animationview.CreateSoundPressure(bodynames, microphoneNames, 10.0, 100.0, 3.0, 1.21E-09, 343000.0, 2000.0, 1, 10, False)

# Close the Pages
# Get all created pages.
# This retrieves all pages created in the application.
pages = applicationHandler.GetPages()
for page in pages :
page.Close()
Expand Down
Loading