# Python Nodes Basics

**URL:** <https://forum.dynamobim.com/t/python-nodes-basics/15872>\
**Category:** Share\
**Tags:** learning\
**Created:** [October 24, 2017, 2:41pm UTC](https://forum.dynamobim.com/t/python-nodes-basics/15872 "2017-10-24T14:41:26Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 14, 2017, 10:31pm UTC](https://forum.dynamobim.com/t/python-nodes-basics/15872/14 "2017-11-14T22:31:52Z")

</div>

This post is about **FUNCTIONS** :

> [@Set Work Plane](https://forum.dynamobim.com/t/set-work-plane/8775/12):
>
> A couple of things: In python def means that a function is defined. Nothing will happen before you call the function. I think you need to convert the reference plane to a sketch plane before it can be used to set the workplane.

> [@List items insert in items of a nested List](https://forum.dynamobim.com/t/list-items-insert-in-items-of-a-nested-list/1340/3):
>
> insert is a function and should use (), not []. slight_smile

> [@Create new project parameter from dynamo](https://forum.dynamobim.com/t/create-new-project-parameter-from-dynamo/7944/2):
>
> you have indentation issues in your code. Indentation is very important in python ! for example, when creating a function, you need an indent, like this : def func(x,y): s = x+y return s read this , it will help you understand and fix your code: [http://www.diveintopython.net/getting\_to\_know\_python/indenting\_code.html](http://www.diveintopython.net/getting_to_know_python/indenting_code.html)

[https://forum.dynamobim.com/t/passing-nodes-as-functions-in-python-script/16324/4](https://forum.dynamobim.com/t/passing-nodes-as-functions-in-python-script/16324/4)

> [@List Process, list map in python](https://forum.dynamobim.com/t/list-process-list-map-in-python/5625/2):
>
> Tomasz, The ProcessList() method takes care of zipping the two arguments from lists. You don’t have to perform that inside your Intersection() method. Basically change it to: def Intersection(elA, elB): return elA.DoesIntersect(elB) Then call it like so: OUT = ProcessList(Intersection, ducts, walls) Make sure that the two lists ducts and walls are exactly of the same structure. It works like this: ducts = [duct1, duct2, duct3] walls = [wall1, wall2, wall3] Calling ProcessList(Interse…

> [@Python script won't work with lists](https://forum.dynamobim.com/t/python-script-wont-work-with-lists/12603/6):
>
> @yyi is right. The problem here is that the code doesn’t accept different types of inputs (single integer or list of integers, single list of strings or nested lists, etc.) What I would do is adapt the code to the worst case scenario for each case, being this when you have nested list of strings for the first one and a list of integers for the second. Pay attention to the if statement using isinstance(). Remove Characters import re inputList = IN[0] outputList = [] def RemoveCharacters(list…

> [@Test the type of geometry](https://forum.dynamobim.com/t/test-the-type-of-geometry/11619/4):
>
> In python it may actually work faster than to convert to some text showing the type name and then testing on that. You could do the same thing there, but there’s a better alternative. Standard python comes with the isinstance function. As an example: [image] In that the Python Code: 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. #Assign your output to the OUT variable. OUT = map…

> [@Set Analytical Floor Alignment](https://forum.dynamobim.com/t/set-analytical-floor-alignment/5538/6):
>
> I took another look at this, but had to turn to python to make it work: (Edit: Python is updated, center and bottom had swapped places) import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB.Structure import \* clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument #Functions for list handling def ProcessList(\_func…

> [@Material Asset Names](https://forum.dynamobim.com/t/material-asset-names/4824/2):
>
> @Chad_Clary, This is indeed a little tricky because these elements don’t have a Parameter called name, but instead its a property. Here’s how you can handle it. Here’s the code that’s inside of Python: # Copyright(c) 2016, Konrad K Sobon # @arch\_laboratory, http://archi-lab.net # Import Element wrapper extension methods import clr clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) # Import DocumentManager and TransactionManager clr.AddReference("Revit…

---

_[View the full topic](https://forum.dynamobim.com/t/python-nodes-basics/15872)._
