diff --git a/2026R1/motion_post_lib_doc-26-r1/changelog_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/changelog_operation_api.md index e9bc39e623..784a803e8b 100644 --- a/2026R1/motion_post_lib_doc-26-r1/changelog_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/changelog_operation_api.md @@ -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()**. \ No newline at end of file +- 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**. \ No newline at end of file diff --git a/2026R1/motion_post_lib_doc-26-r1/example_Import_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_Import_for_operation_api.md new file mode 100644 index 0000000000..776131afb9 --- /dev/null +++ b/2026R1/motion_post_lib_doc-26-r1/example_Import_for_operation_api.md @@ -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) + +``` \ No newline at end of file diff --git a/2026R1/motion_post_lib_doc-26-r1/example_analysis_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_analysis_for_operation_api.md index 43d5a74ee9..856d694231 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_analysis_for_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_analysis_for_operation_api.md @@ -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. @@ -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 @@ -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() @@ -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) @@ -67,7 +244,8 @@ if viewCount > 0 : # isDeicbelScale - The decibel scale. 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() diff --git a/2026R1/motion_post_lib_doc-26-r1/example_animation_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_animation_for_operation_api.md index 5ce50d020b..483a700083 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_animation_for_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_animation_for_operation_api.md @@ -8,10 +8,12 @@ This example demonstrates how to create an animation view suitable for the analy # OperationAPI_CreatingAnimationViewBasedonType.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 @@ -25,9 +27,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() @@ -39,7 +44,14 @@ for page in pages : findViews.append(animationView) +# result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + +# This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics dynamic_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) dynamic_analysis.SetAnimationFrame(50) @@ -47,19 +59,36 @@ viewCount = len(findViews) if viewCount > 0 : page1 = applicationHandler.GetPage(findViews[0].GroupID) - # Types of Analyis Results + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics eigenval_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Eigenvalue) + + # Create an Animation View on the active page + # This will create an animation view based on the eigenvalue analysis. eigenvalue_animation = page1.CreateAnimation(eigenval_analysis, "EigenvalueAnimation") eigenval_analysis.Frame = 100 + # Get Sampling Times + # This retrieves the sampling times from the eigenvalue analysis. times = eigenval_analysis.GetSamplingTimes() convertedtimes = list(times) + + # Set the target sampling time. eigenval_analysis.TargetSamplingTime = convertedtimes[0] + + # Get all instances of frequencies. frequencies = eigenval_analysis.GetFrequencies() + + # Get the frequency instance for the specified sampling time index. frequency = eigenval_analysis.GetFrequency(0) frequency.Enable = 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() @@ -69,17 +98,24 @@ applicationHandler.CloseDocument(result_file_path) ``` -## Contour -This example demonstrates how to create a contour. -Contour is a good tool for analyzing a simulation result. Since scalar data, such as stress, is displayed with color corresponding to value, you can easily estimate where a problem is during an animation. +## Create a Coordinate System +This example demonstrates how to create a coordinate system. +The Coordinate system can be created from various entities in the result as below, and this example describes how to create the Coordinate System. +* Rigid Body +* FE Node +* Marker + ```python -# OperationAPI_CreatingContour.py +# -*- coding: utf-8 -*- +# OperationAPI_CreateACoordinateSystem.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 @@ -93,9 +129,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() @@ -106,32 +145,47 @@ for page in pages : if animationView.DocumentFilePath == result_file_path and animationView.AnalysisResultType == AnalysisResultType.Dynamics : findViews.append(animationView) +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("Crank_CSYS", "Crank") -document = applicationHandler.GetDocument(result_file_path) -dynamic_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) -dynamic_analysis.SetAnimationFrame(10) - -# It returns the objects available for contouring that correspond to the MappingType. -targetentities = dynamic_analysis.GetContourables(ContourMappingType.FENode) + # Get instance of entity + # The GetViewModelByName method retrieves the target by its name. + csys = animationview.GetViewModelByName("Crank_CSYS") -# Create Contour -contour = dynamic_analysis.CreateContour(targetentities, ContourMappingType.FENode, "Displacement", "X") -contour.LegendColorScheme = ColorSchemeType.BLACK_TO_WHITE -contour.AutoRange = False -if contour.AutoRange == False: - contour.Max = 4 - contour.Min = 1 + # Set the transformation offset position and angle for the coordinate system. + csys.TransformationOffsetPosition = Vector(0,10,0) + csys.TransformationOffsetAngle = Vector(1,0,0) + csys.TransformationOffsetRotationType = RotationTypes.FixedAngle + csys.TransformationOffsetRotationAxis = RotationAxes.XYX + csys.MarkerSize = 10 -contour.LegendFontColor = Colors.Red -contour.LogScale = True -contour.LegendVisibility = False -contour.Continuous = True -contour.Component = "Z" -contour.FullName = "FEBody_01_Contour_Z" -contour.MinMaxTargetType = ExtremalValueType.Part -contour.IsEnabled = False + # The CurrentCoordinateSystemType property indicates Type attribute as displayed in the user interface. + # Accepted input values are defined by the GeneralMarkerType enumeration. + # The GeneralMarkerType ρ property must be one of the following: CARTESIAN, CYLINDRICAL, SPHERICAL + csys.CurrentCoordinateSystemType = GeneralMarkerType.CYLINDRICAL + if csys.CurrentCoordinateSystemType == GeneralMarkerType.SPHERICAL: + # The SphericalAxis1 property indicates Axis ρ. Accepted input values are defined by the CoordinateType enumeration. + # The Axis ρ property must be one of the following: X, Y, Z + csys.SphericalAxis1 = CoordinateType.X + # The SphericalAxis2 property indicates Axis Ø. Accepted input values are defined by the CoordinateType enumeration. + # The Axis Ø property must be one of the following: X, Y, Z + csys.SphericalAxis2 = CoordinateType.Y + elif csys.CurrentCoordinateSystemType == GeneralMarkerType.CYLINDRICAL: + # The CylindricalAxisR property indicates Axis R. Accepted input values are defined by the CoordinateType enumeration. + # The Axis R property must be one of the following: X, Y, Z + csys.CylindricalAxisR = CoordinateType.Z + # The CylindricalAxisZ property indicates Axis Z. Accepted input values are defined by the CoordinateType enumeration. + # The Axis Z property must be one of the following: X, Y, Z + csys.CylindricalAxisZ = CoordinateType.X # Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -141,22 +195,18 @@ applicationHandler.CloseDocument(result_file_path) ``` -## Create a Coordinate System -This example demonstrates how to create a coordinate system. -The Coordinate system can be created from various entities in the result as below, and this example describes how to create the Coordinate System. -* Rigid Body -* FE Node -* Marker - +## Create Node & Element +This example demonstrates how to create nodes and elements within a flexible body. ```python -# -*- coding: utf-8 -*- -# OperationAPI_CreateACoordinateSystem.py +# OperationAPI_CreatingANodeAndElement.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 @@ -170,9 +220,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() @@ -185,39 +238,29 @@ for page in pages : viewCount = len(findViews) if viewCount > 0 : - animationview = findViews[0] - # Name - Set the name of instance. - # ParentInfo - Specifies The path of an parent entity. - animationview.CreateCoordinateSystem("Crank_CSYS", "Crank") + # result_file_path - Get the document from the result file path. + document = applicationHandler.GetDocument(result_file_path) - # Get instance of entity view model - csys = animationview.GetViewModelByName("Crank_CSYS") - csys.TransformationOffsetPosition = Vector(0,10,0) - csys.TransformationOffsetAngle = Vector(1,0,0) - csys.TransformationOffsetRotationType = RotationTypes.FixedAngle - csys.TransformationOffsetRotationAxis = RotationAxes.XYX - csys.MarkerSize = 10 + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics + analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) - # The CurrentCoordinateSystemType property indicates Type attribute as displayed in the user interface. - # Accepted input values are defined by the GeneralMarkerType enumeration. - # The GeneralMarkerType ρ property must be one of the following: CARTESIAN, CYLINDRICAL, SPHERICAL - csys.CurrentCoordinateSystemType = GeneralMarkerType.CYLINDRICAL - if csys.CurrentCoordinateSystemType == GeneralMarkerType.SPHERICAL: - # The SphericalAxis1 property indicates Axis ρ. Accepted input values are defined by the CoordinateType enumeration. - # The Axis ρ property must be one of the following: X, Y, Z - csys.SphericalAxis1 = CoordinateType.X - # The SphericalAxis2 property indicates Axis Ø. Accepted input values are defined by the CoordinateType enumeration. - # The Axis Ø property must be one of the following: X, Y, Z - csys.SphericalAxis2 = CoordinateType.Y - elif csys.CurrentCoordinateSystemType == GeneralMarkerType.CYLINDRICAL: - # The CylindricalAxisR property indicates Axis R. Accepted input values are defined by the CoordinateType enumeration. - # The Axis R property must be one of the following: X, Y, Z - csys.CylindricalAxisR = CoordinateType.Z - # The CylindricalAxisZ property indicates Axis Z. Accepted input values are defined by the CoordinateType enumeration. - # The Axis Z property must be one of the following: X, Y, Z - csys.CylindricalAxisZ = CoordinateType.X + # Get a febody + febody = analysis.GetViewModel("FEBody_01") -# Close the Pages + # Create Node + node = febody.CreateNode(754) + node.ChangeID(755) + + # Create Element + element = febody.CreateElement(2343) + element.ChangeID(2601) + +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -227,17 +270,119 @@ applicationHandler.CloseDocument(result_file_path) ``` -## Vector Display -This example demonstrates how to create a vector display. -Vector display is used to display the force vector in animation view. It is a useful tool for analyzing the magnitude or direction of a force. The force and torque of joint, force, and contact are available in the vector display. +## Contour +This example demonstrates how to create a contour. +Contour is a good tool for analyzing a simulation result. Since scalar data, such as stress, is displayed with color corresponding to value, you can easily estimate where a problem is during an animation. ```python -# OperationAPI_CreatingAVectorDisplay.py +# IOperationsContourViewModel.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 all created pages. +# This retrieves all pages created in the application. +pages = applicationHandler.GetPages() + +findViews = list() +for page in pages : + views = page.GetViews() + animationViews = [view for view in views if view.ViewType == ViewType.Animation] + for animationView in animationViews : + if animationView.DocumentFilePath == result_file_path and animationView.AnalysisResultType == AnalysisResultType.Dynamics : + findViews.append(animationView) + +# result_file_path - Get the document from the result file path. +document = applicationHandler.GetDocument(result_file_path) + +# This retrieves the analysis result from the document. +# Types of Analysis Results +# - Dynamics +# - Eigenvalue +# - Statics +dynamic_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) +dynamic_analysis.SetAnimationFrame(10) + +# It returns the objects available for contouring that correspond to the MappingType. +targetentities = dynamic_analysis.GetContourables(ContourMappingType.FENode) + +# Create Contour +# targetentities - Set the entity as the target for export +# 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 +# characteristic_path - The path to the characteristic for which the contour will be created. +# component_path - The path to the component for which the contour will be created. +contour = dynamic_analysis.CreateContour(targetentities, ContourMappingType.FENode, "Displacement", "X") + +# Set properties for the contour +contour.LegendColorScheme = ColorSchemeType.BLACK_TO_WHITE +contour.AutoRange = False +if contour.AutoRange == False: + contour.Max = 4 + contour.Min = 1 + +contour.LegendFontColor = Colors.Red +contour.LogScale = True +contour.LegendVisibility = False +contour.Continuous = True +contour.Component = "Z" +contour.FullName = "FEBody_01_Contour_Z" +contour.MinMaxTargetType = ExtremalValueType.Part +contour.IsEnabled = False + +# 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) + +``` + +## Expression +This example demonstrates how to create a expression. +A Postprocessor Expression is similar to a Function Expression in the Motion Preprocessor. It represents a formula that can be written as a combination of functions of displacement, velocity, and acceleration between specified markers, and it also supports basic mathematical functions. +```python +# OperationAPI_CreatingAExpression.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 @@ -251,9 +396,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() @@ -266,28 +414,22 @@ for page in pages : viewCount = len(findViews) if viewCount > 0 : + # result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) - entity = "TJ_01" - base_force_characteristic = "Base Force" - base_torque_characteristic = "Base Torque" - # Create Vector Display - vector = analysis.CreateVectorDisplay(entity, base_force_characteristic) - vector.IsLabel = True - vector.IsVisible = True - vector.LabelBackgroundColor = OperationAPIService.GetColorFrameRGB(255,255,255) - vector.LabelTextColor = OperationAPIService.GetColorFrameRGB(0,0,0) - vector.FullName = "TJ_VectorDisplay" - vector.IsLog = False - vector.Scale = 1000 - vector.SetCharacteristic(base_torque_characteristic) - vector.Color = Colors.Blue + # Creating a Expression + expression = analysis.CreateExpression("expression") + expression.Expression = "DM(\"Crank/CM\")" -# Close the Pages -pages = applicationHandler.GetPages() -for page in pages : - page.Close() +# Close the Page +page.Close() # Close the Document applicationHandler.CloseDocument(result_file_path) @@ -300,10 +442,12 @@ This example demonstrates how to capture the content on the screen as an image. # OperationAPI_ImageCapture.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 @@ -317,9 +461,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() @@ -332,7 +479,14 @@ for page in pages : viewCount = len(findViews) if viewCount > 0 : + # result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) animationview = findViews[0] @@ -346,7 +500,8 @@ if viewCount > 0 : # Image Caputre animationview.ExportImage(export_filepath, ImageFormat.Png, 1920, 1080) -# Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -362,10 +517,12 @@ This example demonstrates how to record an animation as a video. # OperationAPI_Recording.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 @@ -379,9 +536,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() @@ -394,10 +554,20 @@ for page in pages : viewCount = len(findViews) if viewCount > 0 : + # result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) animationview = findViews[0] + + # Sets a specified number of animation frames. + # This will set the animation frame to the specified number. analysis.SetAnimationFrame(10) specs = animationview.GetViewSpecs() @@ -407,7 +577,8 @@ if viewCount > 0 : # Recording Animation animationview.RecordingAnimation(export_filepath, RecordingType.MP4, RecordingRangeType.ActiveView, 10, specs) -# Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -417,17 +588,19 @@ applicationHandler.CloseDocument(result_file_path) ``` -## Expression -This example demonstrates how to create a expression. -A Postprocessor Expression is similar to a Function Expression in the Motion Preprocessor. It represents a formula that can be written as a combination of functions of displacement, velocity, and acceleration between specified markers, and it also supports basic mathematical functions. +## Vector Display +This example demonstrates how to create a vector display. +Vector display is used to display the force vector in animation view. It is a useful tool for analyzing the magnitude or direction of a force. The force and torque of joint, force, and contact are available in the vector display. ```python -# OperationAPI_CreatingAExpression.py +# OperationAPI_CreatingAVectorDisplay.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 @@ -441,9 +614,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() @@ -456,31 +632,60 @@ for page in pages : viewCount = len(findViews) if viewCount > 0 : + # result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + + # This retrieves the analysis result from the document. + # Types of Analysis Results + # - Dynamics + # - Eigenvalue + # - Statics analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) - # Creating a Expression - expression = analysis.CreateExpression("expression") - expression.Expression = "DM(\"Crank/CM\")" + entityName = "TJ_01" + base_force_characteristic = "Base Force" + base_torque_characteristic = "Base Torque" + + # Create Vector Display + # entityName - The name of the target entity for the vector display. + # base_force_characteristic - The name of the characteristic. Refer to the UI for Vector Display for available characteristics. + vector = analysis.CreateVectorDisplay(entityName, base_force_characteristic) -# Close the Page -page.Close() + # Set properties for the vector display + vector.IsLabel = True + vector.IsVisible = True + vector.LabelBackgroundColor = OperationAPIService.GetColorFrameRGB(255,255,255) + vector.LabelTextColor = OperationAPIService.GetColorFrameRGB(0,0,0) + vector.FullName = "TJ_VectorDisplay" + vector.IsLog = False + vector.Scale = 1000 + vector.SetCharacteristic(base_torque_characteristic) + vector.Color = Colors.Blue + +# Get all created pages. +# This retrieves all pages created in the application. +pages = applicationHandler.GetPages() +for page in pages : + page.Close() # Close the Document applicationHandler.CloseDocument(result_file_path) ``` -## Create Node & Element -This example demonstrates how to create nodes and elements within a flexible body. +## View Entity Management: Show, Hide, and Fit +This example demonstrates how to show, hide, or fit entities within the current Animation View. ```python -# OperationAPI_CreatingANodeAndElement.py +# -*- coding: utf-8 -*- +# OperationAPI_ViewEntityControl.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 @@ -494,41 +699,41 @@ 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 -pages = applicationHandler.GetPages() +# Get Active Page +# This retrieves the currently active page in the application. +page = applicationHandler.GetActivePage() -findViews = list() -for page in pages : - views = page.GetViews() - animationViews = [view for view in views if view.ViewType == ViewType.Animation] - for animationView in animationViews : - if animationView.DocumentFilePath == result_file_path and animationView.AnalysisResultType == AnalysisResultType.Dynamics : - findViews.append(animationView) +# Get Active View +# This retrieves the currently active view in the page. +animationView = page.GetActiveView() -viewCount = len(findViews) -if viewCount > 0 : - document = applicationHandler.GetDocument(result_file_path) - analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) +# Get instance of entity +# The GetViewModelByName method retrieves the target by its name. +febody = animationView.GetViewModelByName("FEBody_01") - # Get a febody - febody = analysis.GetViewModel("FEBody_01") +# Hides all entities except the specified ones. +# In this case, we hide all entities except the FEBody_01. +# Input: febody.FullName +# or Input: febody.ID +animationView.HideOthers(febody.ID) - # Create Node - node = febody.CreateNode(754) - node.ChangeID(755) +# Fit the view to the current selection. +animationView.Fit() - # Create Element - element = febody.CreateElement(2343) - element.ChangeID(2601) +# Show all entities in the view. +animationView.ShowAll() -# Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() -# Close the Document +# Close Document applicationHandler.CloseDocument(result_file_path) ``` \ No newline at end of file diff --git a/2026R1/motion_post_lib_doc-26-r1/example_chart_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_chart_for_operation_api.md index 1921eb2a40..2f66871422 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_chart_for_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_chart_for_operation_api.md @@ -9,11 +9,12 @@ Chart view is useful for analyzing simulation results by using a graph which is # OperationAPI_CreatingAChartView.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 @@ -27,12 +28,17 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 Background @@ -55,10 +61,12 @@ For combinations of paths(Characteristic, Component) on the curve, refer to Comm # OperationAPI_CreatingCurves.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 @@ -72,12 +80,17 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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") # Documentation Example @@ -86,7 +99,11 @@ curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') curvePaths.Add(r'Displacement/Z') -# Set a Curve Parameter +# 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" @@ -116,10 +133,12 @@ It is perform addition, subtraction and multiplication between graphs in the cha # OperationAPI_CreatingAPage.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 @@ -133,20 +152,32 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') curvePaths.Add(r'Displacement/Z') -# Set a Curve Parameter +# 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" @@ -157,18 +188,17 @@ parameters.Target = "Crank" # The instance of the curve. curves = chartView.AddCurves(result_file_path, parameters) -# Documentation Example # SeriesNames - A list of curve names. # SimpleMathType - The types of the simple math are as follows. # Points - The number of data points for interpolation. -# Add +# SimpleMath - Add chartView.CreateSimpleMath(curves, SimpleMathType.Add, 100) -# Subtract +# SimpleMath - Subtract chartView.CreateSimpleMath(curves, SimpleMathType.Subtract, 100) -# Multiply +# SimpleMath - Multiply chartView.CreateSimpleMath(curves, SimpleMathType.Multiply, 100) # Close the Pages @@ -185,10 +215,12 @@ It is transform graphs through translate, align, scale, and absolute in the char # OperationAPI_CreatingATransform.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 @@ -202,20 +234,32 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') curvePaths.Add(r'Displacement/Z') -# Set a Curve Parameter +# 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" @@ -265,10 +309,12 @@ It is interpolate graphs with the desired number of data points in the chart vie # OperationAPI_CreatingAInterpolation.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 @@ -282,19 +328,31 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') -# Set a Curve Parameter +# 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" @@ -325,10 +383,12 @@ It is integrate or differentiate graphs in the chart view. # OperationAPI_CreatingACalculus.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 @@ -342,22 +402,34 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') -# Set a Curve Parameter +# 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" +parameters.Paths = curvePaths # Add Curves (FilePath, Curve Parameter) # FilePath - The path of the result to access. @@ -387,10 +459,12 @@ It is perform data filtering and smoothing of graphs in the chart view. # OperationAPI_SignalProcessing.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 @@ -404,20 +478,32 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') curvePaths.Add(r'Displacement/Z') -# Set a Curve Parameter +# 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" @@ -465,10 +551,12 @@ It is transform data in the time domain to the frequency domain by using the Fas # OperationAPI_CreatingAFFT.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 @@ -482,19 +570,31 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') -# Set a Curve Parameter +# 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" @@ -532,10 +632,12 @@ The short time furrier transformation method(STFT) can transform the data in tim # OperationAPI_CreatingSTFT.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 @@ -549,19 +651,31 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') -# Set a Curve Parameter +# 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" diff --git a/2026R1/motion_post_lib_doc-26-r1/example_export_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_export_for_operation_api.md index ed313fb140..9806448714 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_export_for_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_export_for_operation_api.md @@ -8,10 +8,12 @@ Export all curves on active plot view. # OperationAPI_ExportAllCurves.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 @@ -25,20 +27,32 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView +# 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 +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. curvePaths = List[str]() curvePaths.Add(r'Displacement/Magnitude') curvePaths.Add(r'Displacement/Z') -# Set a Curve Parameter +# 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" @@ -49,13 +63,16 @@ parameters.Target = "Crank" # The instance of the curve. curves = chartView.AddCurves(result_file_path, parameters) +# Change the name of the curves index = 0 for curve in curves : curve.SeriesName = "NameChange_{0}".format(index) index = index + 1 -# Documentation Example -# use not file dialog +# Exporting All Curves +# The output path is 'examples/Output'. +# file_path - The path to the file where the curve data will be exported. +# This function exports all curves in the chart view to a specified file. output_dir = get_output_directory() export_filepath = combine_path(output_dir, r'curvedata.txt') chartView.ExportAllCurves(export_filepath) @@ -68,16 +85,19 @@ applicationHandler.CloseDocument(result_file_path) ``` -## Numeric Import -Here is an example of importing curve results from a file. +## Export Contour Result To File +This example demonstrates how to export contour results to a file. ```python -# OperationAPI_NumericImport.py +# Export.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 @@ -86,63 +106,87 @@ applicationHandler = ApplicationHandler() # Import result file result_file_path = get_result_file_path() -# Set array about result file +# Set array about result file - There may be multiple result files. 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create PlotView -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') - -# Set a Curve Parameter -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() -export_filepath = combine_path(output_dir, r'curvedata.txt') -chartView.ExportAllCurves(export_filepath) - -# Documentation Example -parameters = List[INumericParameter](2) -parameter = NumericParameter() -parameter.Name = r'NameChange_10' -parameter.TargetX = r'X(sec)' -parameter.TargetY = r'NameChange_1' -parameters.Add(parameter) - -# Import Numeric -chartView.ImportNumeric(export_filepath, parameters) +# 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 instance of entity +# The GetViewModelByName method retrieves the target by its name. +febody = activeView.GetViewModelByName("FEBody_01") + +# Check if the FEBody is found +if febody is None: + sys.exit(1) + +# Set Ouput Path - The path where the output will be saved. +output_path = combine_path(get_output_directory(), "Displacement.txt") + +# 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 the febody fullname as the target for export +targetNames = List[str]() +targetNames.Add(febody.FullName) + +# 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.FENode + +# Set Characteristic Path +characteristic_path = "Displacement" + +# Set Component Path +component_path = "X" + +# Combine Characteristic and Component Path +combined_characteristic_component_path = characteristic_path + "/" + component_path + +# Export Contour Result to File - When the Animation View is the Active View +# result_file_path - The path to the result file. +# output_path - The path to the output file where the contour results 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, output_path, targetNames, is_full_frame, contour_mapping_type, combined_characteristic_component_path) # Close the Pages -page.Close() +# Get all created pages. +# This retrieves all pages created in the application. +pages = applicationHandler.GetPages() +for page in pages : + page.Close() -# Close the Document +# Close Document applicationHandler.CloseDocument(result_file_path) ``` \ No newline at end of file diff --git a/2026R1/motion_post_lib_doc-26-r1/example_result_file_reader.md b/2026R1/motion_post_lib_doc-26-r1/example_result_file_reader.md index 5c6056249b..30399e0dd1 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_result_file_reader.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_result_file_reader.md @@ -13,19 +13,20 @@ The Coordinate system can be created from various entities in the result as belo import sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'../../Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file outputReader = OutputReader(get_result_file_path()) -# newName - Specifies the name of the marker. -# parentFullName - Specifies the name of parent. -# Rigid Body +# Create a Coordinate System +# Name - Set the name of instance. +# ParentInfo - Specifies The path of an parent entity. crank_csys = outputReader.CreateCoordinateSystem("Crank_CSYS", "Crank") crank_csys.TransformationOffsetParameters.Angle = Vector(0, 10, 0) crank_csys.TransformationOffsetParameters.Position = Vector(10, 10, 10) @@ -55,11 +56,15 @@ elif crank_csys.GeneralMarkerType == GeneralMarkerType.CYLINDRICAL: # Rigid Body print (f"Marker Name : {crank_csys.FullName}") -# FE Node +# Create a Coordinate System +# Name - Set the name of instance. +# ParentInfo - Specifies The path of an parent entity. fenode_csys = outputReader.CreateCoordinateSystem("NodeCSYS", "FEBody_01/Node/754") print (f"Marker Name : {fenode_csys.FullName}") -# Marker +# Create a Coordinate System +# Name - Set the name of instance. +# ParentInfo - Specifies The path of an parent entity. marker_csys = outputReader.CreateCoordinateSystem("MarkerCSYS", "Crank/CM") print (f"Marker Name : {marker_csys.FullName}") @@ -79,26 +84,46 @@ It is the simplest example of a Python script to print plot data. import sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'../../Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file +# Create an OutputReader instance to read the result file. outputReader = OutputReader(get_result_file_path()) -# Get Curves +# Specify the paths for the curves you want to retrieve. +# For example, Acceleration represents the Characteristic, and Y after the / represents the Component. +# In this case, we are retrieving the Y component of Acceleration for the Crank. +# You can check the available Characteristics and Components for the target by using Add Curve in the Postprocessor. paths = List[str]() paths.Add("Acceleration/Y") +# Create a PlotParameters object to specify the parameters for the plot. plotParameter = PlotParameters() + +# Set the Entity to Plot. +# The Target is the name of the target for which you want to retrieve the curves. plotParameter.Target = "Crank" + +# Set the paths for the curves you want to retrieve. +# This is where you specify the characteristics and components you want to plot. plotParameter.Paths = paths +# There are two ways to retrieve the results of the curve: +# 1. PlotDataType.DEFAULT - Uses the default PlotDataType setting. +# 2. PlotDataType.PlotResult - If a Plt result exists, you can set PlotResult and obtain the result from Plt. +# If PlotDataType is not set, it is set to Default by default. +plotParameter.PlotDataType = PlotDataType.DEFAULT + +# Get curve data from the result. results = outputReader.GetCurves(plotParameter) +# Print the results in a formatted way. for result in results : print(['Time\t', "Y", '\n']) for plotData in result.Value : @@ -118,11 +143,12 @@ Export contour results to a file import struct, os, sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'../../Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file @@ -181,11 +207,12 @@ Export vector results to a file import os, sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'../../Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file @@ -224,11 +251,12 @@ Get results from the Vector. import sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'../../Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file diff --git a/2026R1/motion_post_lib_doc-26-r1/example_view_for_operation_api.md b/2026R1/motion_post_lib_doc-26-r1/example_view_for_operation_api.md index a602f3db42..55a753d2df 100644 --- a/2026R1/motion_post_lib_doc-26-r1/example_view_for_operation_api.md +++ b/2026R1/motion_post_lib_doc-26-r1/example_view_for_operation_api.md @@ -8,10 +8,12 @@ This example demonstrates how to create a page. # OperationAPI_CreatingAPage.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 @@ -25,12 +27,17 @@ 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 Page +# Add a new page +# This will create a new page and activate it. +# You can specify the page name when the page is created. page = applicationHandler.AddPage("FirstPage") -# Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -46,10 +53,12 @@ This example demonstrates how to find and delete a created page. # OperationAPI_FindingAndDeletingAPage.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 @@ -63,9 +72,13 @@ 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) -# Create a page +# Add a new page +# This will create a new page and activate it. +# You can specify the page name when the page is created. applicationHandler.AddPage("FirstPage") # Find a page @@ -74,7 +87,8 @@ page = applicationHandler.GetPage("FirstPage") # Close a page applicationHandler.ClosePage(page.ID) -# Find Page +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() findViews = list() @@ -85,7 +99,8 @@ for page in pages : if animationView.DocumentFilePath == result_file_path and animationView.AnalysisResultType == AnalysisResultType.Dynamics : findViews.append(animationView) -# Close the Pages +# Get all created pages. +# This retrieves all pages created in the application. pages = applicationHandler.GetPages() for page in pages : page.Close() @@ -101,10 +116,12 @@ This example demonstrates how to move a view within a page. # OperationAPI_MovingAView.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 @@ -118,15 +135,31 @@ 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 Page +# Get Active Page +# This retrieves the currently active page in the application. page = applicationHandler.GetActivePage() -# Create View +# result_file_path - Get the document from the result file path. document = applicationHandler.GetDocument(result_file_path) + +# This retrieves the analysis result from the document. +# Types of Analysis Results +# - Dynamics +# - Eigenvalue +# - Statics dynamic_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics) + +# Create an Animation View on the active page +# This will create an animation view based on the dynamic analysis. animation = page.CreateAnimation(dynamic_analysis, "ResultAnimation") + +# Creating a Chart +# Create a new Chart View on the page +# This will create a new chart view with the specified name. chart = page.CreateChart("Chart") # Moving a View diff --git a/2026R1/motion_post_lib_doc-26-r1/getting_started_operation_api_using_py.md b/2026R1/motion_post_lib_doc-26-r1/getting_started_operation_api_using_py.md index f9e3851877..8cb6b0e2a1 100644 --- a/2026R1/motion_post_lib_doc-26-r1/getting_started_operation_api_using_py.md +++ b/2026R1/motion_post_lib_doc-26-r1/getting_started_operation_api_using_py.md @@ -119,9 +119,13 @@ By using the ApplicationHandler class, you can gain a comprehensive understandin ```python # OperationAPIUsingThePythonLanguage.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 @@ -136,6 +140,10 @@ result_file_path = get_result_file_path() paths = List[str](1) paths.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(paths) ``` diff --git a/2026R1/motion_post_lib_doc-26-r1/getting_started_result_file_reader_using_py.md b/2026R1/motion_post_lib_doc-26-r1/getting_started_result_file_reader_using_py.md index 48b1eeec05..a6059c0a44 100644 --- a/2026R1/motion_post_lib_doc-26-r1/getting_started_result_file_reader_using_py.md +++ b/2026R1/motion_post_lib_doc-26-r1/getting_started_result_file_reader_using_py.md @@ -53,11 +53,12 @@ The following sample code demonstrates how to use Result File Reader API : import sys from pathlib import Path +# Get the current file's path and set the path for external modules. current_dir = Path(__file__).resolve().parent - external_modules_path = Path(current_dir, r'./Modules').resolve() sys.path.append('{0}'.format(external_modules_path)) +# Import necessary modules from ResultFileReaderAPI import * # Import result file diff --git a/2026R1/motion_post_lib_doc-26-r1/index.md b/2026R1/motion_post_lib_doc-26-r1/index.md index 78842de14a..18145a32d8 100644 --- a/2026R1/motion_post_lib_doc-26-r1/index.md +++ b/2026R1/motion_post_lib_doc-26-r1/index.md @@ -16,10 +16,11 @@ The Ansys Motion Standalone Postprocessor C# Library is installed with the Ansys Operation script is a useful functionality that allows you to execute functions provided by Postprocess by using Python Script, allowing you to automate repetitive and time-consuming operations using Python Script. For example, you can use operation script to save time by automating everything from creating screens, adding results, Postprocessor results, and importing and using other library modules. (Some features may not be available.) Accessible functionalities by Python operation script: +* [Analysis](example_analysis_for_operation_api.md) * [Animation](example_animation_for_operation_api.md) * [Chart](example_chart_for_operation_api.md) * [Export](example_export_for_operation_api.md) -* [Analysis](example_analysis_for_operation_api.md) +* [Import](example_Import_for_operation_api.md) * [View](example_view_for_operation_api.md) ## Result File Reader diff --git a/2026R1/motion_post_lib_doc-26-r1/lib/VM.API.Post.Operations.ApplicationHandler.md b/2026R1/motion_post_lib_doc-26-r1/lib/VM.API.Post.Operations.ApplicationHandler.md index 35831075ec..58faa161a3 100644 --- a/2026R1/motion_post_lib_doc-26-r1/lib/VM.API.Post.Operations.ApplicationHandler.md +++ b/2026R1/motion_post_lib_doc-26-r1/lib/VM.API.Post.Operations.ApplicationHandler.md @@ -1,30 +1,35 @@ -# Class ApplicationHandler +# Class ApplicationHandler + Namespace: [VM.API.Post.Operations](VM.API.Post.Operations.md) Assembly: VM.API.Post.Operations.dll This is the class to operate the OperationAPI. -```python +```csharp public class ApplicationHandler ``` #### Inheritance -[object](https://learn.microsoft.com/dotnet/api/system.object) ← +object ← [ApplicationHandler](VM.API.Post.Operations.ApplicationHandler.md) ## Examples For an example that includes information about interfaces, see this example. To view the examples, refer to the location of the 'Install_Path\Motion\Document\Postprocessor API for Python.zip' file. -
# ApplicationHandler.py
+```python
+# ApplicationHandler.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
@@ -41,36 +46,70 @@ 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()
+# Change the name of the active page
page.FullName = "Page1"
+# Add a new page
+# This will create a new page and activate it.
+# You can specify the page name when the page is created.
page2 = applicationHandler.AddPage("Page2")
+
+# Activate the first page
page.Activate()
-# Create View
+# result_file_path - Get the document from the result file path.
document = applicationHandler.GetDocument(result_file_path)
+
+# This retrieves the analysis result from the document.
+# Types of Analysis Results
+# - Dynamics
+# - Eigenvalue
+# - Statics
dynamic_analysis = document.GetAnalysisResultViewModel(AnalysisResultType.Dynamics)
-animation = page.CreateAnimation(dynamic_analysis, "ResultAnimation")
+# Create an Animation View on the active page
+# This will create an animation view based on the dynamic analysis.
+animation = page.CreateAnimation(dynamic_analysis, "AnimationView")
-chart = page.CreateChart("Chart")
+# Creating a Chart
+# Create a new Chart View on the page
+# This will create a new chart view with the specified name.
+chart = page.CreateChart("ChartView")
-# The output path is 'examples/Output'.
-output_dir = get_output_directory()
+# The path where the image will be saved.
export_image_filepath = combine_path(output_dir, r'Image.png')
+
+# Export the chart as an image
+# chart - Export the chart view as an image. The export target can be AnimationView or ChartView.
+# export_image_filepath - The path where the image will be saved.
+# ImageFormat.Png - The format of the image to be exported.
+# ImageFormat can be Png, Jpeg, Bmp.
+# Width - The width of the exported image. The optional width for the exported image. If not specified, the original width is used.
+# Height - The height of the exported image. The optional height for the exported image. If not specified, the original height is used.
applicationHandler.ExportImage(chart, export_image_filepath, ImageFormat.Png, 1920, 1080)
-# Get Page
+# Get Page - This retrieves a page by its name.
page2 = applicationHandler.GetPage("Page2")
+
+# Activate the second page
page2.Activate()
# Creating a Chart
+# Create a new Chart View on the second page
+# This will create a new chart view with the specified name.
chart = page2.CreateChart("Chart")
+# Create a Plot data
+# For ImportNumeric, a CSV file is created with sample data.
+output_dir = get_output_directory()
file_path = combine_path(output_dir, r'example.csv')
with open(file_path, 'w') as file:
file.write("X,Y\n")
@@ -78,27 +117,33 @@ with open(file_path, 'w') as file:
file.write("0.5,35\n")
file.write("0.95,75\n")
-# Documentation Example
+# 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'OrderTrackingCurve'
parameter.TargetX = r'X'
parameter.TargetY = r'Y'
parameters.Add(parameter)
-chart.ImportNumeric(file_path, parameters)
-# Add Page
-page3 = applicationHandler.AddPage("Page3")
-page3.Activate()
+# 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.
+chart.ImportNumeric(file_path, parameters)
-# Close the Pages
+# Get all created pages.
+# This retrieves all pages created in the application.
pages = applicationHandler.GetPages()
for page in pages :
page.Close()
# Close the Document
applicationHandler.CloseDocument(result_file_path)
-
+```
## Constructors
@@ -106,7 +151,7 @@ applicationHandler.CloseDocument(result_file_path)
Initializes a new instance of the false.
+
### ExportImage\(IView, string, ImageFormat, double?, double?\)
Exports the current image to a specified file format. This function saves the image to the given file path.
-```python
+```csharp
public void ExportImage(IView viewViewModel, string filepath, ImageFormat format, double? width = null, double? height = null)
```
@@ -313,7 +389,7 @@ public void ExportImage(IView viewViewModel, string filepath, ImageFormat format
Represents the target to be captured.
-`filepath` [string](https://learn.microsoft.com/dotnet/api/system.string)
+`filepath` string
The path where the image file will be saved.
@@ -323,11 +399,11 @@ The format in which the image will be saved. Supported formats are Png, Jpeg, an
The available options are:
# OperationAPIService.py
+```python
+# OperationAPIService.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
@@ -38,12 +42,17 @@ 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 Page
+# Get Active Page
+# This retrieves the currently active page in the application.
page = applicationHandler.GetActivePage()
-# Create PlotView
+# 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")
chartView.Legend.Background = OperationAPIService.GetColorFromHexCode("#FF000000")
@@ -52,13 +61,15 @@ chartView.Legend.FontFace = OperationAPIService.GetFontFaceFromString("Arial")
chartView.Legend.FontStyle = OperationAPIService.GetFontStyleFromString("Italic")
chartView.Legend.FontWeight = OperationAPIService.GetFontWeightFromString("Bold")
+# Get all created pages.
+# This retrieves all pages created in the application.
pages = applicationHandler.GetPages()
for page in pages :
page.Close()
# Close the Document
applicationHandler.CloseDocument(result_file_path)
-
+```
## Methods
@@ -66,27 +77,27 @@ applicationHandler.CloseDocument(result_file_path)
Converts the specified RGB values into a Specifies Angle Type.
-```python +```csharp public enum AngleTypes ``` @@ -23,4 +24,3 @@ public enum AngleTypes - diff --git a/2026R1/motion_post_lib_doc-26-r1/lib/VM.AnonymousDisposable.md b/2026R1/motion_post_lib_doc-26-r1/lib/VM.AnonymousDisposable.md index 7a952e0b0a..cd37fbcac7 100644 --- a/2026R1/motion_post_lib_doc-26-r1/lib/VM.AnonymousDisposable.md +++ b/2026R1/motion_post_lib_doc-26-r1/lib/VM.AnonymousDisposable.md @@ -1,61 +1,61 @@ -# Class AnonymousDisposable +# Class AnonymousDisposable + Namespace: [VM](VM.md) Assembly: VM.dll -```python +```csharp public sealed class AnonymousDisposable ``` #### Inheritance -[object](https://learn.microsoft.com/dotnet/api/system.object) ← +object ← [AnonymousDisposable](VM.AnonymousDisposable.md) ## Constructors ### AnonymousDisposable\(Action\) -```python +```csharp public AnonymousDisposable(Action dispose) ``` #### Parameters -`dispose` [Action](https://learn.microsoft.com/dotnet/api/system.action) +`dispose` Action ## Properties ### IsDisposed -```python +```csharp public bool IsDisposed { get; } ``` #### Property Value - [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + bool ## Methods ### Create\(Action\) -```python +```csharp public static IDisposable Create(Action dispose) ``` #### Parameters -`dispose` [Action](https://learn.microsoft.com/dotnet/api/system.action) +`dispose` Action #### Returns - [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable) + IDisposable ### Dispose\(\) -```python +```csharp public void Dispose() ``` - diff --git a/2026R1/motion_post_lib_doc-26-r1/lib/VM.Collections.ExtendedObservableCollection-1.md b/2026R1/motion_post_lib_doc-26-r1/lib/VM.Collections.ExtendedObservableCollection-1.md index f6e6718ce5..0434e6d85c 100644 --- a/2026R1/motion_post_lib_doc-26-r1/lib/VM.Collections.ExtendedObservableCollection-1.md +++ b/2026R1/motion_post_lib_doc-26-r1/lib/VM.Collections.ExtendedObservableCollection-1.md @@ -1,9 +1,10 @@ -# Class ExtendedObservableCollection