Python Nodes Basics

I noticed it might be useful to gather some Python related posts in one thread to make it easy to get started with some basic understanding (and also for a consultation ease purpose). This is still a work in progress and there might be some slight inconsistencies. Feel free to add your own links or Python related comments, or to PM me on anything that should be revised. This first post relates naturally to tips for LEARNING PYTHON:
http://dynamoprimer.com/en/09_Custom-Nodes/9-4_Python.html
http://dynamoprimer.com/en/09_Custom-Nodes/9-5_Python-Revit.html
http://dynamoprimer.com/en/12_Best-Practice/12-1_Scripting-Strategies.html
http://dynamoprimer.com/en/12_Best-Practice/12-3_Scripting-Reference.html
http://dynamoprimer.com/en/Appendix/A-1_resources.html

30 Likes
List Appearance Assets for Material
Looking for a Simple Python script to create Table (solved without python)
[spring nodes] alter node "FamilyInstance.ByGeometry
Find nodes and packages in use in a graph
Create Elevation by Rooms
Learning Python
Modify Phyton Scripts
Change the Curve that determines the 2D extents of Grids in Each View
Get the calculated values of a table
How to write FamilyTypes and selected family files into PythonScript in the form of code?
Source Code of "out of the box" nodes
Missing Crop Region Shape
Learning Python online
Python. clean list if other list have empty sublists at same indices
Example python node needed
Multi-Category Schedule
How to use Revit SDK?
Materials to help understand how to use Python with Dynamo
Getting started with Dynamo Studio 2016
DynamoRevit + Python References
The managed object is not valid - Dynamo crashes on 'TransactionManager.Instance.EnsureInTransaction(doc)'
Created nested lists with python
Override Element Colour/Color (but not line)
Learn Python for Dynamo: The Dynamo Python Primer
Set analytical column Z Projection parameter
Looking to edit Schedule Filters via Player Input
Automatic dimensioning of (multiple) detail lines
Code Block working with List
Using Dynamo to filter families from a type catalog based on an excel workbook
Python Cheat Sheet
How to filter SchedulableFields considering only the ones deriving from shared parameters?
Copy, paste in place and change to a different type with python
Python. Create Points from item numbers of sublists and remove items and leave the point instead
How to get the area of a surface in Python script
XYZ List -Points

This second post relates to IMPORTS:

https://forum.dynamobim.com/t/how-to-convert-dynamo-nodes-to-python-script/13050/2

https://forum.dynamobim.com/t/rounding-numbers-in-python/14671/11

8 Likes

This third post is about REVIT API and C# TO PYTHON:

http://thebar.cc/converting-revit-api-c-code-to-python/

http://thebuildingcoder.typepad.com/blog/about-the-author.html

9 Likes

@Yna_Db

Give a man a fish and he can eat for a day.
Give a man a fishingrod and he can eat for a lifetime.

Thnx
Marcel

4 Likes

Totally agree :slight_smile:
This post relates to IRONPYTHON and its LIBRARIES:
http://ironpython.net/
http://www.ironpython.info/index.php?title=Useful_Links
http://opensimulator.org/git/opensim-libs-save/IronPython/IronPython-1.1.1/Tutorial/Tutorial.htm
https://ironpython-test.readthedocs.io/en/latest/

https://ironpython-test.readthedocs.io/en/latest/library/index.html
https://docs.python.org/2/library/intro.html
http://ironpython.net/documentation/dotnet/

3 Likes

This post is a selection of COMMENTED SCRIPTS:

1 Like

Totally agree, but the main problem in the forum is that some users are still doing the work of some lazy people.

Regards,

2 Likes

@Organon
I can’t resist to cite your very first lesson to coding in this thread 'cause I simply love it :grinning:

4 Likes

@Yna_Db,

Hahaha, it’s the hard truth.

Regards,

1 Like

… so much easier to say with a touch of humor :grin:

3 Likes

To complement this IF-ELSE STATEMENT proposal, here are a few additional examples:
https://forum.dynamobim.com/t/if-list-is-empty-switch-to-another-list/14720/6

https://forum.dynamobim.com/t/wall-property-function/11685/9
https://forum.dynamobim.com/t/msgbox-and-if-statement/12993/13

The following posts are related to PYTHON LISTS:

https://forum.dynamobim.com/t/lacing-on-replacing-item-on-index/16462/11
https://forum.dynamobim.com/t/help-with-group-by-key/11379/8

2 Likes

These posts relate to STRINGS in Python:

https://forum.dynamobim.com/t/combine-nested-list-items-into-one-multiline-string/13158/2
https://forum.dynamobim.com/t/list-replace-multi-elements/13010/7

This post is about FUNCTIONS:

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

I wrote a 30 page handout for my AU class on Python for Dynamo, thought I would leave this here

13 Likes

This is a very good document that let you get started with a clear view on the possibilities opened by this language, along with a few tips that will make it all fun from the start. I add a link into the introductory post so it can be found easily. Thanks a lot :grinning:

Hooray for this post

It seems consistent to add this other nice tutorial here:

7 Likes

For a non-programmer like myself, which would be the natural course then?
I am assuming first learning the basics of Python, for which I am following some course on edX and reading some tutorials, but this doesn’t seem to relate to geometric or graphical capabilities at all (Which I assume is because of the introductory level of the course).
So what would be next after learning the basic stuff?
How can I connect Revit or Dynamo or both to Python? This is like the missing link for me. I am sure you will guide me, and many others after me, on the right path.
Thank you all.

For most Dynamo users, I would say that Python only really shines when dealing with lists (especially of multiple levels) and Revit API work (which are things usually done in C# but can be done in python nodes). For geometric capabilities, I can only think of python being useful for its import libraries, math functions/capabilities, looping, or if you can find a python function online that already has what you want.

Someone please correct me if I am wrong though.

1 Like