I am running Civil3D 2025 on Windows and am developing a script in Dynamo to talk to a local installation of postgres, extract table data (geometry and attributes) and process the data down the line.
The issue I am facing is that I have no idea where the Python Interpreter for Civil3D is located (CPython), if you can add custom packages to it or potentially how to change the directory of said interpreter to say the “Windows System” Python installation.
Does anyone have any experience with this, any ideas and hints are welcome.
If there is an easier way to talk to postgis via dynamo, that is also very much on the table.
If anyone could take a look or point me in the right direction, I’d really appreciate it.
Thank you for any and all help in advance!!
I don’t think it’s worth fighting changing the interpreter, there is a reason the Dynamo team hasn’t pushed out other engines for Python - it isn’t easy.
You may also want to consider using the PythonNet engine instead, or the IronPython3 engine. Both of which are available on the Dynamo package manager.
As another option you could write the program in C# and use a collection of zero touch nodes which are both orders of magnitude faster than the Python ones and keep your code obfuscated.
As a final option, you could write a Dynamo Python node to call your Python application and return the results back to Dynamo. This would be very cumbersome due to the nature of interop and therefore won’t scale as well, but it might be the quickest to build.
Thank you for the feedback, these are some excellent ideas I’ll have a look what would work best and document it later!
What are the advantages of the PythonNet3 or the IronPython engine? In the end it really just comes down to extracting table information from PostGres.
Either way thank you for your valuable input already!
Each engine has it’s own limitations around what it can do within the .NET environment. These are limitations from the team which builds the Python engine, not Dynamo or others. The need and reasoning stems from where the code executes - natively Python in C which is one step closer to machine code than the .NET environment where Revit, Civil3D, and Dynamo run, and as such things have to be converted from .NET to C and back to .NET again (in some cases several times), which can cause issues. For your use case I think you can work with any of the options as it shouldn’t be impacted, which would make the default preferable as it will be one less dependency to manage.
Thanks again for the tips and lightning speed responses. I ended up writing my own Node in C#, mainly with Npgsql and am using it dynamically to parse the entire database table at once through to a Dynamo System.Data.DataTable (12.000 rows, so not too bad).
Could definitely improve downstream, but this dataset is representing the sewage network in a small town, and won’t scale much higher. Plus it’s more a proof of concept, I’m just happy that it ended up being “that simple”
Considering you went from ‘ask’ to ‘working’ in about a day, I’d say that’s a HUGE win! Nice work!
You might want to consider presenting the result at a conference or in a blog post should the POC prove to work out well, as this is the type of thing which can be a big differentiator for a business.