Become a Dynamo Zero Touch C# Node Developer in 75 Minutes

zerotouch
csharp

#1

Dear Dynamo aficionados

I recently hosted a lab at the BILT EUR 2018 conference in Ljubljana, Slovenia teaching the basics of Dynamo Zero Touch node development using C# in Visual Studio…in 75 minutes.

For those who did not attend the BILT conference this year but are interested in C# node development, I’ve attached the full dataset from lab, including the 60-page handout, for your delectation.

The exercises are ideal for those looking to acquire coding skills but do not know where to start, or for experienced Dynamo users reaching the limits of visual programming. If you’re an IronPython developer, but wary of strong-typed languages such as C#, this is a great opportunity to overcome any barriers and develop skills using an elegant language with a powerful IDE.

Why Develop Nodes in C#?

There are numerous reasons to create Zero Touch nodes using C#, including:

  • Fully integrated in an IDE (Visual Studio), providing IntelliSense and debugging which make coding easier than any other option (and yes, that includes IronPython)
  • Speed – Zero Touch nodes execute rapidly making them ideal for complex problems on large projects
  • Full access to the Revit API, Dynamo API and ability to communicate with external applications
  • Code is more secure and easier to protect if IP is a concern

Lab Contents

The lab – or rather, the handout and exercises – are delivered through practical exercises covering:

  • Visual Studio and Zero Touch environment configuration
  • Key C# and Zero Touch Concepts
  • Creating namespaces, classes, methods and properties
  • Creating compiled assemblies and Zero Touch import
  • Navigating the Revit API and making API calls in your nodes

Before starting, ensure the following software is installed:

  1. Revit 2018.3
  2. Dynamo 2.0
  3. Visual Studio Community 2017 – Use the Visual Studio Installer and select/install the .NET Desktop Development Workload
  4. Revit Lookup

Handout

The handout is available for download on the link below. The handout covers the exercises from the lab, with tips and useful links throughout the document. I recommend undertaking the handout exercises while referencing the presentation slides as this will aid your understanding of the concepts.

Download the handout

Presentation and Tips + Tricks

I’ve published the presentation and Tips + Tricks slides on my website news articles. If you want to view and download them, click the link below:

See the Presentation and Tips + Tricks slides

GitHub Repo - Get the Source Code

You can compile the lab project exercises from source by downloading it from the Bimorph GitHub repository to your local machine on the link below. If you get stuck, or find things just aren’t working as you undertake the exercises, then you may find it useful to compare your progress against this repo and ‘reverse-engineer’ it to improve your understanding.

The GitHub repo is located here: BILT EUR 2018 Dynamo ZeroTouch Source Code

To download the repo, we recommend using the GitHub desktop app. Download it from github.com. Once installed, launch the app and click on File > Clone Repository. In the dialog box that opens, click on the URL tab and copy/paste the repo URL into the Repository input box and select a location on your local machine to save the files. Click the Clone button to complete this step:

To open the project, simply browse to the location where you saved the project and open the ZeroTouchNodes.sln file and Visual Studio will launch (make sure it is already installed!). To build the solution, click Project > Build and if it is successful, you will see the ZeroTouchNodes library appear in Dynamo.


#2

Very interesting work! Especially as C# might be a big mouthful to take on for the average dynamo user, this will ease the process! :slight_smile:


#3

#4

Pinned this to the developers category. Thanks for the great info @Thomas_Mahon!


#5

Really nice, Thomas. Looking forward to go through this :wink:


#6

Nice work @Thomas_Mahon!


#7

Thanks for all the comments! Be great to see more ZT nodes on the package manager.


#8

I remember back in '08 I wanted to learn C# & get into Revit Macros. Got me what’s basically a C# For Dummies book, but got too wrangled up with BIM Mgmt. to have time to dive in deep. Now with Dynamo being more matured I’ve restarted that track this past weekend. Wish I had this earlier or that I could’ve attended Bilt this year. I was going Google/YouTube crazy trying to find a good How To that made sense. Thank you for making it easier now.


#9

Thanks @cftrevizo that’s good to hear. I understand where you are coming from; interestingly enough I never recommend any programming books or courses as they are always overkill for construction professionals given that most of the concepts serve little to no purpose for most use-cases. Scripting languages like DesignScript attempt to address this, but it has a long way to go before its reliable enough to act as a replacement.

With C# or Python then, only a very narrow part of the language needs to be understood to be proficient - gaining a broader understanding is only necessary if looking to specialise in software development IMO - and this is where the difficult lies when trying to find the right learning resources, as there little out there which specifically targets the practical application of programming in construction.


#10

Yes yes yes…

Though if I ever need to create an automatic grocery list I now have the skills :smiley:

Thanks Thomas, this is an awesome resource.

Cheers,

Mark


#11

@Mark.Ackerley the beauty of programming is, its only limited by one’s imagination - if you need an automated grocery list, you can do it. Thanks for the feedback; I look forward to seeing that grocery node on the package manager.


#12

@Thomas_Mahon :smiley:

I feel like I can work my way through Python issues with the help of google… My major limitation is interpreting C# into Python to make use of the API. Resources like yours make that feel more achievable.

Thanks again,

Mark


#13

To add to @Thomas_Mahon’s excitement, I’ll expect to see an optimization routine for where to put the food in the Pantry/Fridge to reduce the rate of spoiled food.

Let me know what it’s like working at Amazon after you release it.


#14

Thank you @Thomas_Mahon for sharing

Really appreciate your work ! for sure i will go through it :+1:


#15

Killer tutorial! Only comment I would have is that you comment your code target 1.3, but the “copy and paste” part actually targets 2.0. Most people at this stage should be able to figure it out, but thank you for this, its awesome introduction!


#16

Thanks @Sean1, thats great to hear. Well spotted, I’ve updated the document accordingly (same link)!