Setup Your Own Python Template
Last updated
Last updated
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}\ )
.
In order to utilize this functionality we need to add the following line in our DynamoSettings.xml
file. (Edit in notepad)
Where we see <PythonTemplateFilePath />
, we can simply replace this with the following:
Note: replace CURRENTUSER with your username
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:
Once that is done, save this file as PythonTemplate.py
in the APPDATA
location.
A_f_ter 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.
If the Python template is found (like our Revit one for example) you will see all of the default items you built in.
Additional information regarding this great addition (by Radu Gidei) can be found here. https://github.com/DynamoDS/Dynamo/pull/8122