.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/00_basic/example_03_show_object_properties.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_examples_gallery_examples_00_basic_example_03_show_object_properties.py>` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_examples_00_basic_example_03_show_object_properties.py: .. _ref_example_03_show_object_properties: Display properties for an object --------------------------------- Using supplied files, this example shows how to display the properties that you would see in an object's details view. .. GENERATED FROM PYTHON SOURCE LINES 12-15 Download required files ~~~~~~~~~~~~~~~~~~~~~~~~ Download the required files. Print the file path for the MECHDATA file. .. GENERATED FROM PYTHON SOURCE LINES 15-24 .. code-block:: default import os from ansys.mechanical.core import launch_mechanical from ansys.mechanical.core.examples import download_file mechdat_path = download_file("example_03_simple_bolt_new.mechdat", "pymechanical", "00_basic") print(f"Downloaded the MECHDAT file to: {mechdat_path}") .. rst-class:: sphx-glr-script-out .. code-block:: none Downloaded the MECHDAT file to: /home/runner/.local/share/ansys_mechanical_core/examples/example_03_simple_bolt_new.mechdat .. GENERATED FROM PYTHON SOURCE LINES 25-30 Launch Mechanical ~~~~~~~~~~~~~~~~~ Launch a new Mechanical session in batch, setting ``cleanup_on_exit`` to ``False``. To close this Mechanical session when finished, this example must call the ``mechanical.exit()`` method. .. GENERATED FROM PYTHON SOURCE LINES 30-34 .. code-block:: default mechanical = launch_mechanical(batch=True, cleanup_on_exit=False) print(mechanical) .. rst-class:: sphx-glr-script-out .. code-block:: none Ansys Mechanical [Ansys Mechanical Enterprise] Product Version:231 Software build date:Sat Nov 26 20:15:28 2022 .. GENERATED FROM PYTHON SOURCE LINES 35-39 Initialize the variable needed for this workflow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set the path for the ``mechdat_path`` variable for later use. Make this variable compatible for Windows, Linux, and Docker containers. .. GENERATED FROM PYTHON SOURCE LINES 39-56 .. code-block:: default project_directory = mechanical.project_directory print(f"project directory = {project_directory}") # Upload the file to the project directory. mechanical.upload(file_name=mechdat_path, file_location_destination=project_directory) # Build the path relative to project directory. base_name = os.path.basename(mechdat_path) combined_path = os.path.join(project_directory, base_name) mechdat_path_modified = combined_path.replace("\\", "\\\\") mechanical.run_python_script(f"mechdat_path='{mechdat_path_modified}'") # Verify the path. result = mechanical.run_python_script(f"mechdat_path") print(f"MECHDATA file is stored on the server at: {result}") .. rst-class:: sphx-glr-script-out .. code-block:: none project directory = /tmp/AnsysMech9A75/Project_Mech_Files/ Uploading example_03_simple_bolt_new.mechdat to 127.0.0.1:10000:/tmp/AnsysMech9A75/Project_Mech_Files/.: 0%| | 0.00/7.06M [00:00<?, ?B/s] Uploading example_03_simple_bolt_new.mechdat to 127.0.0.1:10000:/tmp/AnsysMech9A75/Project_Mech_Files/.: 100%|##########| 7.06M/7.06M [00:00<00:00, 686MB/s] MECHDATA file is stored on the server at: /tmp/AnsysMech9A75/Project_Mech_Files/example_03_simple_bolt_new.mechdat .. GENERATED FROM PYTHON SOURCE LINES 57-61 Execute the script ~~~~~~~~~~~~~~~~~~ Run the Mechanical script to display the properties and their current values for the analysis object. .. GENERATED FROM PYTHON SOURCE LINES 61-79 .. code-block:: default result = mechanical.run_python_script( """ import json ExtAPI.DataModel.Project.Open(mechdat_path) analysisSettings = Model.Analyses[0].AnalysisSettings props = {} if hasattr(analysisSettings,'VisibleProperties') != False: for prop in analysisSettings.VisibleProperties: props[prop.Caption] = prop.StringValue json.dumps(props, indent=1) """ ) print(f"AnalysisSettings properties:\n{result}") .. rst-class:: sphx-glr-script-out .. code-block:: none AnalysisSettings properties: { "Contact Summary": "Program Controlled", "Delete Unneeded Files": "Yes", "Volume and Energy": "Yes", "Nonlinear Data": "No", "Combine Restart Files": "Program Controlled", "Force Convergence": "Program Controlled", "Step End Time": "1. s", "Rotation Convergence": "Program Controlled", "Solver Unit System": "mks", "Generate Restart Points": "Program Controlled", "Coriolis Effect": "Off", "Number Of Steps": "10.", "Contact Data": "Yes", "Inverse Option": "No", "Auto Time Stepping": "Program Controlled", "Stress": "Yes", "Strain": "Yes", "Result File Compression": "Program Controlled", "Future Analysis": "None", "Solver Units": "Active System", "Large Deflection": "Off", "Back Stress": "No", "General Miscellaneous": "No", "Scratch Solver Files Directory": "", "Nodal Forces": "No", "Save MAPDL db": "No", "Nonlinear Solution": "No", "Current Step Number": "1.", "Euler Angles": "Yes", "Store Results At": "All Time Points", "Newton-Raphson Option": "Program Controlled", "Moment Convergence": "Program Controlled", "Solver Type": "Program Controlled", "Inertia Relief": "Off", "Weak Springs": "Off", "Solver Pivot Checking": "Program Controlled", "Contact Miscellaneous": "No", "Solver Files Directory": "/tmp/AnsysMech9A75/Project_Mech_Files/example_03_simple_bolt_new_Mech_Files/Static Structural (2)/", "Stabilization": "Program Controlled", "Contact Split (DMP)": "Off", "Line Search": "Program Controlled", "Quasi-Static Solution": "Off", "Retain Files After Full Solve": "No", "Displacement Convergence": "Program Controlled" } .. GENERATED FROM PYTHON SOURCE LINES 80-83 Clear the data ~~~~~~~~~~~~~~ Clear the data so it isn't saved to the project. .. GENERATED FROM PYTHON SOURCE LINES 83-86 .. code-block:: default mechanical.clear() .. GENERATED FROM PYTHON SOURCE LINES 87-90 Close Mechanical ~~~~~~~~~~~~~~~~ Close the Mechanical instance. .. GENERATED FROM PYTHON SOURCE LINES 90-92 .. code-block:: default mechanical.exit() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.999 seconds) .. _sphx_glr_download_examples_gallery_examples_00_basic_example_03_show_object_properties.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_03_show_object_properties.py <example_03_show_object_properties.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_03_show_object_properties.ipynb <example_03_show_object_properties.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_