Adding a file to a project

This example shows how to add one or more output files to an existing project configuration. This is a typical scenario when the DCS project is automatically generated by Ansys Workbench and you would like to further customize it.

As a starting point, we consider the project included in the DCS tutorial Bicycle Wheel – Parameter Study. The project consists of a parametric model of a bicycle wheel and uses Ansys Mechanical for the structural simulation.

Here we show you how to modify the project in order to pick up the Mechanical solve.out file for every design point. To begin with, you need to copy the solve.out file to the directory of the project. To this end, we create two simple APDL command snippets as shown in the screenshot (the same is done for the radial local case).

bicycle project command snippet

Then, once the project is sent to the DCS server via Workbench, we can add the solve.out files to the list of collected output files using the Python client.

from ansys.dcs.client.dps import Client, File
client = Client(dcs_url="https://127.0.0.1/dcs", username="dcadmin", password="dcadmin")

# Get the project and its current configuration
proj = client.get_project(id="DPS_Mechanical_Bicycle_Wheel_2019R3")
cfg = proj.get_configurations(id=1)[0]

# Define new file objects
additional_files = []
additional_files.append(File( name="solve_lateral_force_out", evaluation_path="lateral_force.out", type="text/plain", collect=True ) )
additional_files.append(File( name="solve_radial_force_out", evaluation_path="radial_force.out", type="text/plain", collect=True ) )

# Add new files to the list of project files
files = proj.create_files(additional_files)

# Get file IDs
solve_1_out = files[0]
solve_2_out = files[1]

# Add the new files to the list of existing output files
cfg.process_steps[0].output_file_ids.extend([solve_1_out.id, solve_2_out.id])

# Send the modified project configuration to the server
cfg = proj.update_configurations([cfg])

Once the design points are evaluated, you will be able to view the solve output files in the DPS Web APP as well as to download them using the Python client as shown in the previous example.