Exporting object data to SDF/SHP

If you want to invest time in GDAL, you better look at the APIs in Civil 3D. It is default available and you don’t need other libraries.

It’s not easy, when you don’t have experience with Python or other language, but GDAL isn’t either.

@mzjensen Have you found any solution for exporting lines from Civil as shp or sdf ? Im also looking for a solution but i think Im stuck for the moment :frowning:

Not really…my solution for now is a Python node that sends a string of inputs to the command line for the -MAPEXPORT command (i.e. without the dialog box). Not very elegant, but it works for now.

@mzjensen

Do you maybe have a screencast from your workflow today?
We would alos like to export the SHP files via Dynamo. But maybe it is more convenient to provide this via FME.

@mzjensen, @JacobSmall, @Anton_Huizinga, @Andrew_Hannell @cristi.balaban

I spoke last week with Mohsen Assaqqaf about exporting SHP out of Civil 3D via Dynamo.
We currently see 2 possibilities:

  1. Export shp files with DynaMaps (@Mostafa_El_Ayoubi) if it is possible?
    https://dynamobim.org/dynamaps/

  2. To do it in just Dynamo with Zero-Touch nodes and work with the API that Civil 3D provides.
    https://github.com/DotSpatial/DotSpatial

Do you have another idea or agreement with the above?

Thanks in advance.

Python

2 Likes

@Paolo_Emilio_Serra1

Do you have tips to start with this?

Thanks in advance.

MAPEXPORT is the easiest- but it depends if you have specific requirements that this command does not address.

Shapefiles are widespread and reliable- but fairly old technology with some limitations- such as only storing a single geometry type.
Generally speaking, spatial databases such as Spatialite or SDF (a flavour of spatialite), or full-blown databases such as Postgres/PostGIS are more flexible- but it depends what you want to achieve.

@Andrew_Hannell

What we currently want to achieve is the following:
C3D (polygones) -> Dynamo (SHP) -> Infraworks (SHP)

Maybe DynaMaps can help us to get the polygones in Dynamo, in Dynamo we need to provide a Python node that can export the data to SHP format (as indicated by @Paolo_Emilio_Serra1) .

Hello, why not to export to sqlite? https://knowledge.autodesk.com/support/autocad-map-3d/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/MAP3D-Use/files/GUID-B4CD55ED-560D-42C7-8348-66AE770B2342-htm.html
https://ironpython-test.readthedocs.io/en/latest/library/sqlite3.html

1 Like

I’d start here: https://pypi.org/project/pyshp/

C3D is irrelevant as you learn how to use that. Just write a few polygons or whatever out to SHP. Then transition to D4C3D and a real data set. Then work on the import step.

1 Like

You might be over-complicating it. If all you want to do is export stuff to a shapefile- MAPEXPORT will do just that.

I would do the following:

  1. Carry out an initial export of polygon geometry to a SDF file
  2. Load this SDF file back into C3D, and add any attributes etc, or use C3D to edit the data- either geometry or attributes. You can certainly query this data with Dynamo & it looks like you can modify it too, using nodes such as SetProperyValueByName- but I have not tried this
  3. Load the SDF file into Infraworks. This does work pretty well- you make an edit in C3D then hit refresh in Infraworks

Hope this helps

Do you have experience with this Drbohlav?

No, Sorry.

This is my method as well. I’ve found that MAPEXPORT is the easiest, but the problem is that I typically want many separate SDF files to import into InfraWorks as coverage areas because then they will show up separately in the surface layers window. That way you can toggle the visibility on/off for individual layers. With MAPEXPORT you can export multiple features along with their CAD layer attribute to a single file, but then in InfraWorks you only have one data source and therefore lose the visibility control.

Hence the need to automate. Here’s a screen recording of my current solution, which I don’t really like, but it works. It basically just builds up a big string to send to the command line and execute the MAPEXPORT command multiple times. Eventually I want a more direct export method via the Map API, but for now this works.

MapExportTest.dwg (386.5 KB)
MapExportByLayer.dyn (61.3 KB)

4 Likes

@mzjensen

Is it true that we still miss the output (Python node)?


Fig. 1


Fig. 2

Thanks in advance.

@j.boonen I’m not sure why it’s like that, it doesn’t do that on my end. Anyway, here is the code, it’s just a few lines to send a string to the command line.

import System
from System import *

output = "Error"
inputList = IN[0]

app = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application")
adoc = app.ActiveDocument
for i in inputList:
	adoc.SendCommand(i)

OUT = "Success"
2 Likes

Hi Mzjensen .I want to export to shapfile( not SDF) the way above, then I need edit positions in file "MapExportByLayer "

Hi. I’m trying to send the string “The area is …” and the problems is that it’s getting send character by character and each character gets treated as a command. Maybe I’m doing something wrong. Can you help me? Thanks.
areasHatch.dyn (13.2 KB)

Try passing the string into a List Create node prior to passing it into the Python node.