Automate SHP Data Connection in Civil 3D using Dynamo

Hello everyone,

I’m looking to fully automate the process of adding an SHP Data Connection in Civil 3D using Dynamo.

Manually, the workflow is:

  • Planning and Analysis

  • Connect

  • Add SHP Connection

  • Assign a name with the prefix SHP_

  • Select the SHP file path

  • Connect

  • Add to Map

The goal is to reproduce this entire workflow through Dynamo, so that by providing a string input with the SHP file path, the SHP Data Connection is created and added to the map automatically, without any manual interaction.

I would like to know:

  • If this is possible using Dynamo nodes or packages alone

  • Or if Python within Dynamo is required to achieve 100% automation

Any guidance or confirmation from people who have implemented this would be greatly appreciated.

Thank you.

Note: I tried this Python code, but I get a DLL error because it’s not installed by default in Civil 3D 2024.

I’m not sure, maybe the C3DToolbox had such nodes, but that package is only supported to Civil 3D 2024. Afaik there are no packages who can do this.

What is the reason you want to automate this? I assume editing the graph or selecting a path in Dynamo Player is not much faster or easier than the manual process.

the GIS capabilities of Civil3D/Map3D are basic at best. It usually gets you 70% of where you want to go, before you give up & use QGIS or something else…

This is the way I’ve achieved something similar:

  • in C3D/M3D, connections to a SHP file or any other datasource can be saved to a .layer file
  • These can be loaded- useful for transferring the same setup across drawings
  • the .layer file is just an XML file with a bunch of attributes and elements which define the layer connection name, source, styling etc
  • 95% of these XML files is about styling- the important attributes in your case would be:
<Name>DefaultFileLocation</Name>

<Value>C:\temp\myfile.shp</Value>

or some of the

<rdf:Description>

ones

  • I wrote a bunch of these .layer (XML) files programatically using a different method, but could possibly be done in Dynamo using some of the XML nodes
  • I’ve generated quite complex XML (or was it JSON…?) files in Dynamo before
  • So you might have a CSV data file which contains all the SHP file names, layer descriptions etc, and it generates corresponding .layer files- which you can then easily load.
  • Otherwise, some copy/pasting/find&replace in a text editor might work

Hope this helps

1 Like