Dynamo Python Primer
  • Take Dynamo Further 🚀
  • 1 Hello Python 🐍
    • 1.1 Why Should I Learn to Code?
    • 1.2 Python Introduction
    • 1.3 What is IronPython?
  • 2 Seeing The Bigger Picture 🔭
    • 2.1 Context Matters
    • 2.2 What is an API?
    • 2.3 The .NET Framework
    • 2.4 Object-Oriented Programming
  • 3 Getting Started 🛴
    • 3.1 Dynamo's Python Node
    • 3.2 Boilerplate Setup Code
    • 3.3 Basics: Input and Output
    • 3.4 Common Errors
  • 4 Revit-Specific Topics 🏡
    • 4.1 Introduction to Revit's API
    • 4.2 How to Read Revit's API Documentation
    • 4.3 Doc, UIDoc, App, UIApp
    • 4.4 Unwrapping Revit Elements
    • 4.5 The FilteredElementCollector
    • 4.6 Geometry Conversion Methods
    • 4.7 Working With Parameters
      • Family Parameters
      • Global Parameters
      • Project Information Parameters
      • Group Parameters
      • Built-In Parameters
    • 4.8 Working With Transactions
    • 4.9 Opening & Closing External Files
    • 4.10 Prompting UI Selection
    • 4.11 Working With Units
    • 4.12 Built-In Categories
    • 4.13 Family Acrobatics
    • 4.14 Feedback: TaskDialogs
  • 5 Glossary 📚
  • About This Primer 👋
Powered by GitBook
On this page

Was this helpful?

  1. 3 Getting Started 🛴

3.3 Basics: Input and Output

Python nodes work like other nodes; they can take inputs and return outputs

Previous3.2 Boilerplate Setup CodeNext3.4 Common Errors

Last updated 5 years ago

Was this helpful?

Inputs and Outputs

IN and OUT are important keywords in Dynamo's Python node. The 'IN' keywords tells the node to refer to any data which is sent to the node via its inputs.

Don't forget your scripts will always need up top!

The various inputs are accessed via their indexes, like the list_of_numbers below:

#Boilerpate Code Always Goes Up Top! Don't forget it!

input_list_of_numbers = IN[0] #Here we take an input
output_list_of_numbers = [] #We create an empty list to output

for number in input_list_of_numbers: #Looping through input
    new_number = number + 1 #Adding 1 to each number
    output_list_of_numbers.append(new_number)

OUT = output_list_of_numbers #Here we output the new '+1' list

In this example, we're initially creating an empty list for our output. We loop through each number in the input list and add its incremented version to our output list. Finally, we output the incremented list via the 'OUT' keyword.

In practice, it looks like this:

Kinds of Inputs and Outputs

The Dynamo node can take any kind of data as an input and output any kind of data as an output. It is able to take element (e.g. Revit elements), abstract numbers, strings, Dynamo geometry and everything else as inputs.

However, there is one caveat when inputting Revit elements to a Python node. Revit elements need to be 'unwrapped' before they can be accessed via the API. Learn more about unwrapping elements here:

4.4 Unwrapping Revit Elements
boilerplate code