> 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/pl/8_coding_in_dynamo/8-3_python/3-python-templates.md).

# Konfigurowanie własnego szablonu w języku Python

W dodatku Dynamo 2.0 można określić domyślny szablon `(.py extension)`, który ma być używany podczas otwierania okna języka Python po raz pierwszy. Od dawna proszono o dodanie tej funkcji, ponieważ przyspiesza ona korzystanie z języka Python w dodatku Dynamo. Dzięki możliwości użycia szablonu można przygotować domyślny import gotowy do użycia, gdy chcemy utworzyć skrypt niestandardowy w języku Python.

Położenie tego szablonu to `APPDATA` dla instalacji dodatku Dynamo.

Zwykle jest to ścieżka `( %appdata%\Dynamo\Dynamo Core\{version}\ )`.

!

### Konfigurowanie szablonu

Aby korzystać z tej funkcji, należy dodać następujący wiersz w pliku `DynamoSettings.xml`. *(Edytuj w Notatniku)*

!

Część `<PythonTemplateFilePath />` można po prostu zastąpić następującą treścią:

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

{% hint style="warning" %}
\_Uwaga: zastąp element CURRENTUSER nazwą użytkownika\_
{% endhint %}

Następnie musimy utworzyć szablon z funkcjami, które mają być wbudowane. W tym przypadku osadźmy powiązane z programem Revit importy i niektóre inne typowe elementy podczas pracy z programem Revit.

Można rozpocząć od pustego dokumentu Notatnika i wkleić do niego następujący kod:

```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
```

Po zakończeniu zapisz ten plik jako `PythonTemplate.py` w lokalizacji `APPDATA`.

### Późniejsze zachowanie skryptu w języku Python

Po zdefiniowaniu szablonu w języku Python dodatek Dynamo będzie go szukać po każdym umieszczeniu węzła w języku Python. Jeśli go nie znajdzie, okno będzie wyglądać jak domyślne okno języka Python.

!

Jeśli szablon w języku Python zostanie znaleziony (np. nasz szablon dotyczący programu Revit), zostaną wyświetlone wszystkie domyślne wbudowane elementy.

!

Dodatkowe informacje dotyczące tego wspaniałego dodatku (którego autorem jest Radu Gidei) można znaleźć tutaj. <https://github.com/DynamoDS/Dynamo/pull/8122>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://primer2.dynamobim.org/pl/8_coding_in_dynamo/8-3_python/3-python-templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
