> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Script Tip Friday- Create and export contact tool results for all time steps

The brilliant Pernelle Marone-Hitz, Lead Application Engineer at Ansys, is back again for this week's Script Tip to show us how to create and export contact tool results for all time steps.

![](https://developer.ansys.com/sites/default/files/inline-images/Pernelle.png)

Let's break down the following scenario:

"Using ACT scripting, I would like to create a contact tool pressure result for all contacts with names ending by "YES". Then I would like to export the contact pressure results to a text file, for each time step."

The following script can be adapted to do this:

* Define path to where results will be exported:

```python theme={null}
FilePath="C:\\Users\\pmaroneh\\Downloads\\"
FileExtension=r".txt"
```

Reference some necessary items:

```python theme={null}
analysis =  ExtAPI.DataModel.Project.Model.Analyses[0] # change number of analysis if necessary
  solution = analysis.Solution
  connections = ExtAPI.DataModel.Project.Model.Connections
```

* In connections, find children that are contacts and create a list of these contact regions:

```python theme={null}
contactList = connections.GetChildren(DataModelObjectCategory.ContactRegion,True)
```

* From this list, create another list for contacts which name end by "YES":

```python theme={null}
myContactList = [contact for contact in contactList if str(contact.Name).endswith("YES")]
```

* For contacts in myContactList, create a contact tool / pressure result:

```python theme={null}
listContactIds=[contact.ObjectId for contact in contactList] # list of ids of items in contactList
  pressureList=[]
  for contact in myContactList: # loop on all contacts in myContactList
      newContactTool = solution.AddContactTool() # add a Contact Tool
      # remove all scoped contacts
      for id in listContactIds:
          newContactTool.InternalObject.RemoveScopedContact(id)
      # add scoping for contact
      newContactTool.InternalObject.AddScopedContact(contact.ObjectId)
      # add a pressure result
      pressure = newContactTool.AddPressure()
      # change result name
      pressure.Name="ContactPressure_" + contact.Name
      # store reference to result to reuse it later
      pressureList.append(pressure)
```

* Loop on all time steps and export results:

```python theme={null}
resultData = analysis.GetResultsData()
  dataSets=resultData.ListTimeFreq # get result sets
  for resultSet in range(len(dataSets)):
      displayTime=dataSets[resultSet] # select display time
      unitTime='[sec]'
      # loop on pressure results
      for result in pressureList:
          # change display time
          result.DisplayTime=Quantity(str(displayTime) + unitTime)
          # evaluate result
          result.EvaluateAllResults()
          # export result
          result.ExportToTextFile(FilePath+result.Name+"_Time_"+str(displayTime)+FileExtension)
```
