> For the complete documentation index, see [llms.txt](https://primer2.dynamobim.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://primer2.dynamobim.org/8_coding_in_dynamo/8-3_python/3-python-templates.md).

# Setup Your Own Python Template

With Dynamo 2.0 we have the ability to specify a default template `(.py extension)` to use when opening the python window for the first time. This has been a long-desired request as this expedites the usage of Python within Dynamo. Having the ability to use a template allows us to have default imports ready to go when we want to develop a custom Python script.

The location for this template is in the `APPDATA` location for your Dynamo install.

This is typically as follows `( %appdata%\Dynamo\Dynamo Core\{version}\ )`.

![](/files/VPUUgpUigwiAZcNJjMZF)

### Setting Up The Template

In order to utilize this functionality we need to add the following line in our `DynamoSettings.xml` file. *(Edit in notepad)*

![](/files/KkOoOtLxyETa7epxepGD)

Where we see `<PythonTemplateFilePath />`, we can simply replace this with the following:

```
<PythonTemplateFilePath>
<string>C:\Users\CURRENTUSER\AppData\Roaming\Dynamo\Dynamo Core\2.0\PythonTemplate.py</string>
</PythonTemplateFilePath>
```

{% hint style="warning" %}
*Note: replace CURRENTUSER with your username*
{% endhint %}

Next we need to build a template with the functionality that we want to use built-in. In our case lets embed the Revit related imports and some of the other typical items when working with Revit.

You can start a blank notepad document and paste the following code inside:

```py
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

# Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

OUT = element
```

Once that is done, save this file as `PythonTemplate.py` in the `APPDATA` location.

### Python Script Behavior After

After the python template is defined, Dynamo will look for this each time a Python node is placed. If it is not found it will look like the default Python window.

![](/files/ukpqCOpK8UdbBprHZwn4)

If the Python template is found (like our Revit one for example) you will see all of the default items you built in.

![](/files/IA2G5Bxd9aAXGdNKWZWQ)

Additional information regarding this great addition (by Radu Gidei) can be found here. <https://github.com/DynamoDS/Dynamo/pull/8122>
