I can’t find the Dynamo Nodes I need. “It’s so easy,” everybody says. “Just use Python.”
Begging everyone’s pardon, but can anyone explain what this Python thing is? I get absolutely nothing from >>>10.4 Python Nodes<<< in the Dynamo Primer.
Quote: “The examples in this section assume a basic familiarity with Python.” They recommend that if you don’t have a breezy familiarity with Python, go here, go there, blah, blah, blah…rabbit hole after rabbit hole.
Best I can figure is that Python is a 6GB download. All the sites I looked at described a labyrinthian 100-page, vaguely worded, loading process that is waaaaaay beyond my capabilities. Then if you’re able to load Python onto your Windows XP computer(can’t find anything for Windows 10), then you use the Command Line, a 40-year-old concept that is in itself completely unknowable.
Is it just me?
Dave
Hey Dave,
Python is an awesome language once you learn it, but it certainly takes a few go arounds. I recommend this as a learning path:
- Basic Python: Nothing fancy, and you won’t use it to directly solve any problems of significance in your work, but it will give you the foundation which the primer indicates. No specific tool is better or worse for you, but I picked up my skills using the SoloLearn iPhone app on my train rides to and from work.
- The PythonNet / IronPython .net Integration(s): This is the stuff you need to know in order to get Python to ‘hook’ into the application you want to interact with. It’s simple enouhg for Civil 3D and Revit once you learn the basics, and even other applications can be ‘hooked’ this way allowing you to integrate with them more completely too. The best i know for this is the DynamoPythonPrimer, which unfortunately is focused on Revit side of things (that’s what happens when a user base gets a 8 year head start). The core concepts are still valid and worth reading, you can mostly reverse engineer the content on the Civil 3D side of things with that foundation.
- Your Host API: This is a never-ending task; in 8 years as a Dynamo user and 4+ years working with customers around the world I have yet to find anyone who knows every aspect of the API. Learning how to navigate it and find your way should be the goal. I haven’t used Python in Civil 3D (I’m not a Civil 3D user, but a Dynamo user) so I can’t help with great links there.
- Using 3rd (4th? 5th?) Party Toolsets: This is where you can really start to be creative and make what was impossible yesterday rudimentary today. These tutorials should focus on the tool in the context of ‘pure Python’; the implementation of that tool into the CPython/IronPython environment will be on you.
Considering this is the 2nd or 3rd such request on this topic, and I have a bit of a support network to build stuff to educate, I’ll see if I can get a more direct learning pathway started, starting with the foundation of Python splitting into Revit and Civil 3D at #3 above. No timeframe on anything, but I’ll do my best to get it out there somewhere, even if just rambling blog or forum posts.
Thanks Jacob. That Dynamo Python Primer is one I hadn’t seen, so I’ll go through that tonight.
There seems to be a dozen or more versions of Python out there. Any recommendation on which one to get? And how does Python hook up to Dynamo?
Dave
The ‘install on my PC’ flavor should come with your Dynamo installation, so I would use that. Not sure where they are but if you search your PC for IronPython that might get you started. If you are still stuck finding one when I get back into work mode I will find the path.
The ‘learning’ flavor isn’t as big a deal up front in part 1. For the code you might write, things that apply to 2.x Python mostly apply to 3.x, and vice versa.
Seems like the answers are a bit on the complex side… it’s simpler than the primer puts it.
Python is already in Dynamo, no need to install it. Important to decide ‘why’ to learn Python before diving in, for most it is to use the Revit API - so be ready to use that as well.
If it’s just for dynamo then forget about pythonshell, pip, installers etc. Just make a python node and right click, edit. You’re in Python at that point. Some resources that teach vanilla python will do things that Dynamo doesn’t such as printing your results - we store them in the output variable in Dynamo (OUT = your result).
I made a quick ramping series to get people into python for dynamo on my channel, covers most of the fundamentals: Python 101 - YouTube
The Revit API is a beast to tackle, far harder than Python. The python primer might help there:
Thanks Jacob!
Dave
Hi Gavin,
Thank you. I’m learning Dynamo for Civil 3D. Nothing in particular, but I’ve seen a couple of examples of things Dynamo can do that OOTB Civil 3D can’t. And to fill in the gaps where I can’t find the Node I need, I think Python might be a good thing.
That’s quite an impressive Channel you’ve got. Looks like I’ll be watching some YouTubes tomorrow.
Dave
Ah in that case @zachri.jensen would be worth reaching out to. He manages one of the most prolific Dynamo packages for Civil 3D (Camber) and probably knows the best resources to guide you to for Civil API/packages to learn from.
Hi Dave,
There are some great answers here from Jacob and Gavin, so I’ll just try add a few more thoughts. This turned out to be a long one, so buckle up
Jacob alluded to this with his steps 1-3, but I want to spend a little more time on it. Learning Python is one thing, and learning what to do with it in the context of Dynamo and Civil 3D is a very different thing. At the most basic level, Python is a programming language, of which there are hundreds and hundreds out there. It happens to be one of the most popular languages, and has taken the top spot as the most popular language many times (depending on who you talk to). I’m sure there are many reasons for this, but I think some of the key factors are:
- Compared with other languages, it is relatively easy to learn and use
- There is a very large and supportive community around it
- It is very flexible, reliable, and fast
I won’t put words in the mouths of the Dynamo development team, but at some point I would guess that somebody asked the question “if we want to give users some access to behind-the-scenes stuff via Dynamo, what language should we choose?”, to which the answer is pretty easy: Python.
I know exactly what you are getting at here. Dynamo for Civil 3D is still relatively new and is still in its infancy. The number of nodes that are included without any additional packages is pretty limited, but it will continue to grow over time (further development is on the public roadmap for Civil 3D - scroll all the way to the right). And as you’ve found, most of the examples and training material for Dynamo are slanted towards Revit users. But as Jacob said, this is because Dynamo has its origins in the architecture space and has been integrated with Revit for a very long time. So for us civil engineers and surveyors, it’s going to be a bit of a bumpy ride for awhile, but I feel confident that it’ll get there.
So as a user, you have a choice: do you wait for the Civil 3D development team to add the functionality that you need, or do you dive into the deep end and try to customize things yourself? It sounds like you’re leaning more towards the latter, to which I applaud you!
So then the next question is, how do you go about doing that?
I don’t fully disagree with your statement above about learning Python, but I want to offer another perspective. As mentioned earlier, Python is a very popular programming language and is absolutely one of the best ones to learn as a first language. But when talking about customization for Civil 3D, you’ll be hard-pressed to find Python show up in any conversation anywhere outside of this forum. The reason for this is that most plugins/tools for Civil 3D utilize its .NET API, and Python really isn’t a first choice when it comes to .NET development. There could be an unnecessary tangent here about other Python implementations like IronPython, but the fact is that .NET-enabled languages like C# and Visual Basic are much more widely-used and supported.
Taking a deeper dive into customization has a steep learning curve, but it will be rewarding. I’ll take Jacob’s recommended learning progression and tweak it just a little bit:
-
Learn the fundamentals of programming. Starting with Dynamo is a good start! Visual programming is a great way to quickly learn about how to put together a sequence of steps to programmatically achieve an output from a set of inputs. But for further customization, it’s going to be necessary to get into textual programming and writing code. Any language will work for this, but learning Python is an excellent place to start with this. Like Jacob said, you won’t use it to directly solve any problems of significance in your work. On the flip side, there are a ton of free resources out there to learn Python once you decouple it from any Autodesk products and just work on learning it standalone.
-
Get a basic understanding of object-oriented programming. You don’t have to learn everything about this - just the tip of the iceberg. A basic understanding of classes, inheritance, constructors, properties, and methods will go a long way towards understanding how to navigate the AutoCAD and Civil 3D .NET APIs. Again, this learning doesn’t have to be specific to any language as it is more of a programming paradigm, so Google and YouTube are the places to start.
-
Once you’re feeling solid with 1 and 2, then things will start to make a lot more sense when you start working with the AutoCAD and Civil 3D APIs. Without the foundation of 1 and 2, it will be confusing and not have any context to fit into. All of the documentation for the AutoCAD and Civil 3D APIs is available online (AutoCAD, Civil 3D), and the My First AutoCAD Plugin guide is a great step-by-step resource.
I’ll wrap up now. This is all probably a much more complicated answer than you were hoping for. However, there are a lot of code examples floating around on this forum that are the result of copying/pasting/modifying without the authors really understanding what they are doing or where the code came from in the first place. I do not exclude myself from this category - there are several examples that I’ve posted that I am not proud of. Going through the steps above earlier would’ve helped with that. But the other perspective on this is that all of those code samples (good or bad) document the journey that we’re all on.
So dive in. Write some bad code, share it, learn from it, and before you know it you’ll have an entirely new set of tools to build things that you didn’t even know were possible. We’re all here to help.
Awesome summary - knew I was tagging the right person! Keep up the awesome work with Camber and all you do on the forums as well, it’s satisfying to see you driving interest in Dynamo for so many civil engineers out there. I used to have to say ‘sorry I can’t help there’ to those who came to me back in the day, but now I just tell them to go the forums and install Camber.
Thanks Zachri. I don’t know whether to feel enthused or terrified.
Whenever I see someone doing something with software, something great or even next-level awesome, my first thought is how did he learn to do that.
I’ll stick my nose into the .NET API tent flap, and I guess I need to look at the Civil 3D Developers Forum. And I’ll dive head-first into that My First AutoCAD Plug-in Link.
Thank you for your time and encouragement.
Dave
Thanks Gavin! Tell them they can contribute too
I’m always looking to hear what people want to see next, and if they want to dive into it themselves, even better!