# Creating a Custom Python Class

**URL:** <https://forum.dynamobim.com/t/creating-a-custom-python-class/2707>\
**Category:** Packages\
**Created:** [December 14, 2015, 8:12am UTC](https://forum.dynamobim.com/t/creating-a-custom-python-class/2707 "2015-12-14T08:12:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Al1](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Al1](https://forum.dynamobim.com/u/Al1)\
**Post date:** [December 14, 2015, 8:12am UTC](https://forum.dynamobim.com/t/creating-a-custom-python-class/2707/1 "2015-12-14T08:12:13Z")

</div>

Hi, I’ve recently been learning Dynamo and when I get to working with Python Scripts I run into a lot of questions. I couldnt find similar questions in the community so here they go:

In a Python Script node, is it possible to define a custom Python Class, populate it and pass it around as an argument? I would be looking to do something like this:

&nbsp;

` import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN`

`class Circ:
parent=’‘
tipe=’‘
name=’’`

`var=Circ()`

`var.name=‘Nombre’`

`var.tipe=IN`

`OUT=var`

If this cannot be done, can I create my own classes in a separate python file and then import it in my Python scripts? How can I go about doing this?

&nbsp;

Thank you for your help

&nbsp;

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [December 14, 2015, 9:15am UTC](https://forum.dynamobim.com/t/creating-a-custom-python-class/2707/2 "2015-12-14T09:15:44Z")

</div>

It seems that you can create custom classes in one python node, then pass them around the graph and read the properties of the instance in another python node. I was actually a bit surprised by that. I don’t think I’d recommend this method for making custom classes in Dynamo tho.

![2015-12-14_22-47-36](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/d/d97dedaacd79115ba27dd92f884b10f28f062c5b.png)

---

<div class="post-metadata">

**Author:** ![Al1](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Al1](https://forum.dynamobim.com/u/Al1)\
**Post date:** [December 14, 2015, 10:24am UTC](https://forum.dynamobim.com/t/creating-a-custom-python-class/2707/3 "2015-12-14T10:24:08Z")

</div>

It works, Thanks!

I will be using the class to order data from a messy excel sheet and pass it around the nodes as a Data Struct. Do you know of a better way of creating custom classes in Dynamo?

&nbsp;

Again, thanks for your reply!

---

<div class="post-metadata">

**Author:** ![Konrad\_K\_Sobon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/konrad_k_sobon/32/8838_2.png) [@Konrad\_K\_Sobon](https://forum.dynamobim.com/u/Konrad_K_Sobon)\
**Post date:** [December 14, 2015, 3:01pm UTC](https://forum.dynamobim.com/t/creating-a-custom-python-class/2707/4 "2015-12-14T15:01:50Z")

</div>

AL,

You can define those classes inside of Python and pass them around but I prefer to define classes outside of Dynamo in a module file because that gives me access to them from any custom node without having to define it again.

Thanks!
