C# Or Python


#1

So, I have been learning Python, partly as a better way to loop in Dynamo, but just as much to get access to the Revit API…

The Python node in Dynamo is talked about a lot so I presumed this was the only option. However as the API is in C# I’m having to mess around interpreting it into Python, when I’m a basic Python user and have no knowledge of C# this is painful.

Then I find out about this node! C# CSharp in Dynamo Am I better off jumping to C#? It might be more to learn to start with, but I won’t have to interpret so much and I’m happy just pulling a few bits of info to supplement my nodes…

All views appreciated :smiley:

Thanks,

Mark


#2

aren’t you nerdy enough by now?

:slight_smile:


#3

No. Not even close. Like maybe 1/3 of an acceptable level of nerdyness.

On the ‘cool’ side of the C# interpreter, you can do all the cool C# things and Revit API is a bit easier to work with as the examples are all given in that language.

On the ‘not cool’ side, you’ll be somewhat stuck with the functional limits of that node.

Personally, I always viewed that node as the ‘gateway’ to making your own C# library of custom nodes. Way easier to test with the string of code than compiling a custom node each time. That said, I have yet to take that plunge so I cannot conform it’s a good path or not.


#4

Personally, I think that the C# scripting node has a lot of quirks on its own, like having to cast everything to the right type and making sure you’ve referenced all the dlls. I’ve never ended up using it in any custom nodes or projects, and instead have been using it just for testing specific sections of C# code. It’s only strength is that you can use existing inputs straight from dynamo and that you don’t have to worry about compiling or restarting Revit because some DLLs got locked.

On the other hand, the python script node does a lot more hand holding for you and there’s a lot less things to worry about. You will find a ton of examples on the dynammo forum or inside of custom nodes in people’s packages. In general there’s going to be a lot more people around that can help you with your own python code on the forums too.


#5

Thanks for the insight! Useful as always. :slight_smile:


#6

Start with Python; its way more forgiving if you’ve not coded before and just want to have scripting skills you can mix into your day job. Ultimately, knowing both will give you the most flexibility; its important to know that the right tool for the right job also applies with programming languages. Plus, if you learn one, you’ve pretty much learnt the other, at least from a conceptual standpoint. You don’t need C# to access the Revit API either; IronPython is .NET enabled and the syntax for making Revit API calls is practically identical to C# just less verbose (so you could argue, better for getting started). There are some nuances where this rule of thumb doesn’t apply, but they are few and far between.

The main advantage with C# is the fact you can develop in a full IDE, which is ideal for developing complex programs or solving complex (design?) problems. Paradoxically, its also the ‘easiest’ option for developing by virtue of the IDE, the catch being you need to understand basic comp-sci paradigms and the language of course, before you can do anything useful with it. Python on the other-hand has a reasonable text editor, which can be improved with stubs (which emulates IntelliSense in Visual Studio), but you cant really compare the two as its really just a halfway-house at best.