Classes in Dynamo


Dynamo to me is a pretty functional programming language, in the sense that it is great to automate a lot of time consuming operations. In any powerful programming language you learn about at least two things: functions and classes.

Dynamo got functions down almost to a tee. Classes however seems to be a different can of worms. It doesn’t appear to lend itself for OOP, meaning you can’t easily make an object of a certain class and fill it with data.

Now imagine, if you will, the following. What used to irk me is that a function can only return one parameter. The value of that parameter can be a list. If you want to use the Original list or the new list for some new calculations, returning a different set of values - you’re out of luck, you’ll have to write a new function. Were it not for the powerful list operations in Dynamo: combine and transpose. Basically, you can run two operations on a list in one function, fetch the results in two seperate lists, and combine them. You’ll end up with one list containing two sublists, both having as many items as in the Original list (unless you’ve done some filtering first ofcourse). Now with transpose list, you’ll end up with as many sublists as there are items in the Original list, each sublist containing multiple values of multiple types (can be a string, or a number, a family definition, a point or a solid etc).

Sounds like the making of a class to me, with the exception that those properties aren’t read-only, meaning you can’t Get or Set a certain value in an individual instance of that class (unless you write a new abstract function to do so, but that would be taking the long route).

What I’m trying to get across here is this: how useful would it be to use what is in essence a Multi-dimensional array to make it behave as if it were some primitive sort of Class? And more to the point: how likely is it that Dynamo will support classes in the near future?



I don’t quite comprehend the references to classes and OOP.

However, from what I gather, the issue raised seems to be based on the assumption that “a function can only return one parameter

The example below shows that it isn’t necessarily the case



Cool, I didn’t know that.

OK the best way to explain OOP (Object Oriented Programming) is to compare them to Revit families. From an object you must be able to create multiple instances, and it also needs to have some abstraction (meaning parameters that can be set). And inheritance is also a need, for example Floor, Roof and Wall could have one class from which they inherit certain properties (boundries with their start- and endpoints, material etc), while their own class definition has some more specific properties. In a line for example, this can be startpoint, endpoint, vector and length. The line is an object from the class Line which has these properties.
Start- and endpoint ofcourse are from the class Point, which has the properties X, Y and Z which are co-ordinates measured over those three axes. So Dynamo can use predefined classes that also exist in their partner Autodesk products (Revit, Vasari etc) but you can’t make new classes.

What I described is a workaround to deal with lack of classes. For instance if you want to define a line that doesn’t just have a startpoint, vector and length but also a name, you could make a sublist that holds the name in the first row, startpoint in the second row etc, and then perform operations based on the name you’ve given to the line. This in my opinion, like a family, conforms to the conditions of abstraction, repetition and inheritance.