Accessing all of an elements properties in a python node


I have a list of elements I’m sending into a python node(just showing one currently), but I have a few issues. Is there a way to access all of the parameters of an element inside the python script(Shown below what the node equivalent is)? Not that I will use them all but I’d like to be able to make if conditions around as many parameters as I can. Should I even be developing these scripts in the python node or is there an IDE/SDK that transfers easily? Also is there a way to output more than just “OUT” or would I be better off doing a nested list and just outputting that.

First, no, you cant get more than one output on a python script, you have to nest lists in the single output, and use a code block (A[some number]) or the “Get item at index” node to “break apart” your nested lists.

Python scripts are extremely powerful in Dynamo, if you can learn Python enough to use it with Dynamo nodes, your going to be able to write some awesome programs. I would say keep using Python, not only will it run faster than 20 nodes performing the same task, it is also less prone to “breaking”, and unlike using external package add ins that sometimes update their custom nodes, your Python node will never update itself and leave the rest of your graph broken downstream.

As far as your first question is concerned, I’m sort of confused as to what you want… Are you asking to do take the nodes you have in the picture and turn them into one Python node? If so, there probably is, but I do not know how. What I tend to do is use Dynamo for what its best at… retrieving information from Revit and Excel, and writing it back… then I use Python custom scripts to manipulate the lists into useful information, then send the information back to Dynamo nodes to write back data to either Revit or Excel. Python supports writing to Excel but its easier and better to use Dynamo for that. As far as accessing Reivt using Python…I’m sure its possible but that would take some serious coding knowledge that I don’t posses.

1 Like

Honestly I’m a lot more familiar with Python than I am Dynamo. I would prefer to write python scripts for the most part I just struggle relating Python to the nodes I’m trying to use it with. I believe you’re right so I’m probably going to scrap most of what I’ve done using Nodes and redo it using a python script. So my next question would be how do I know what methods and attributes are attached to the elements I’m “UnWrapping”? When I used to use an IDE it would guide me towards what I was looking for, essentially making my life a lot easier. Is there an equivalent that I can use for python instead of using the python script node within Dynamo? So I have a python script below and I’m trying to get its parameters but I have no idea what “get_Parameter()” takes. Do I use the Revit API to figure out what arguments it takes? Sorry if my terminology isn’t the best its been awhile since I’ve coded.

That is a huge downfall to using the Python nodes… as you probably know, IDE’s make coding a lot easier, debugging easier, and even makes typing faster and easier with auto fills and things. There really is no way to use a python node like you would your IDE. The syntax is the same, it will compile the same, but as far as user interface, what you see is what you get… There’s no hidden settings to help make life easier while coding in a Python node.

Now with that said, it puts users in a great spot to use Dynamo. If you want to write your whole code in Python… well then go use your IDE, Dynamo isn’t for you. But if you have a entry - mid level programming skill set and live in Revit most of your day. Dynamo is perfect for you.

My advice… for what its worth, this isn’t some sort of golden rule… Use Dynamo to make your life easier. Why struggle to shove all your code in one Python script then spend hours debugging what Dynamo already does. Don’t re-invent the wheel. Sure it will take a week, but once you get the hang of Dynamo, its super simple. As I mentioned before… I use Dynamo out of box nodes to fetch my information out of Revit. Once Dynamo has got all my parameters I want to use, I will then set up python nodes to process, sort, get rid of, add to, etc. all my parameters. I find Dynamo is great at getting at getting the information I want, but slightly lacking in its ability to manipulate lists. Dynamo can do some basic list manipulation, but for complex manipulation the Python nodes are much quicker and easier assuming you have some basic coding knowledge

1 Like


you can actually get all those returns you want from a python node.

if you example have three things you want out, then write
OUT = t1, t2, t3

after the node you then put a codeblock


this is now three outputs. In a Custom node you then add three “output nodes”

here is an example

Correct @erfajo, I believe we are talking about the same thing, so correct me if I’m wrong, but isn’t what your describing taking t1, t2, t3 and making them all sub lists of OUT then using the code block to get each sub list? So yes, you can output whatever you want, but you can never make a Python node do this: Capture

That is what I was inferring, in my response

try to look here…

1 Like

Correct, but it really doesnt matter, while you can do it the way I describe… You could do it in the same way for the input node as well if you wanted.
Meaning… putting a code block in front of the python node feeding an IN list containing IN[0], IN[1], IN[2], ect.

1 Like

Did you manage to solve this issue? @anelson, I am struggling in the same problem