Touch base with Python in dynamo for civil 3d

Hi
Any direction to a start point of learning how to write python code in dynamo for civil 3d?

thanks

Hi
This page explains, but in C# language

There is a video on YouTube about it in Python but in Russian

https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=GUID-DE3A46DA-508E-43A0-8538-C77D978D06B2

2 Likes

@mzjensen any references ?

For me there are basically 3 things to learn here :

  • Python - there are many courses on LinkedIn, Coursera, EDX, Udemy, etc. to learn the basics of programming plus the Python Primer
  • AutoCAD API
  • Civil 3D API

For this two, best thing to do is look at the posts in this forum and see the code that has been posted. Like this one : Run DYnamo Script on entire folder of dwg's - #11 by Paolo_Emilio_Serra1

Personally, I’ve found that the trickiest thing is to navigate the API (particularly AutoCAD’s) to find the class/method /property that you’re looking for but there are many examples in other forums especially with C# that show you the logic needed. After, it is just a matter of syntax.

My recommendation is to first learn the basics of Python (could take a couple of weeks or months depending on your previous experience and the time you can dedicate to it) and then try to tackle a specific problem. You can get inspiration from this forum, for example solving this using the View class : Zoom to a specific location in model space - #2 by david_licona

2 Likes

Great points David, I was going to say something very similar.

For these items, maybe we could take it one step further and generalize it to two steps:

  • Learn the basics of any object-oriented programming language
  • Learn how to work with .NET

This question has been asked several times on the forum, and in my opinion, searching for a specific “Python for Dynamo” training course (or waiting for someone to create one) is a dead end. When it comes down to the fundamentals, there isn’t anything that one can do with Dynamo that can’t already be accomplished through the .NET APIs for AutoCAD/Civil 3D. Dynamo just removes a few headaches and makes creating automation routines a little easier/more accessible for beginners. But when you come to the point where you need to accomplish something beyond what is available in node form, you have to learn object-oriented programming and .NET. There’s no way around it.

The Developer’s Guide for AutoCAD is laid out very well and should be the starting point for anyone trying to become familiar with how the APIs work.

5 Likes

Try out my 10 part Python series (free) on YouTube. I made it with the purpose of exposing people to the fundamentals of the language as they best apply to using it in Dynamo later on. It doesn’t cover any Revit/Dynamo/API, just Python concepts and statements that you will typically be using in Python for Dynamo:

4 Likes

Thanks All very much

1 Like