.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "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 ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_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 in the Mechanical GUI. .. GENERATED FROM PYTHON SOURCE LINES 12-15 Download required files ~~~~~~~~~~~~~~~~~~~~~~~ Download the required files. Print the file path for the MECHDAT file. .. GENERATED FROM PYTHON SOURCE LINES 15-26 .. code-block:: Python 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 27-32 Launch Mechanical ~~~~~~~~~~~~~~~~~ Launch a new Mechanical session in batch, setting the ``cleanup_on_exit`` argument to ``False``. To close this Mechanical session when finished, this example must call the ``mechanical.exit()`` method. .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python 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:242 Software build date: 06/03/2024 09:35:09 .. GENERATED FROM PYTHON SOURCE LINES 37-41 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 41-58 .. code-block:: Python 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/ANSYS.root.1/AnsysMech3D4E/Project_Mech_Files/ Uploading example_03_simple_bolt_new.mechdat to dns:///127.0.0.1:10000:/tmp/ANSYS.root.1/AnsysMech3D4E/Project_Mech_Files/.: 0%| | 0.00/7.06M [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_03_show_object_properties.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_03_show_object_properties.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_