Issue with SendCommand and MapImport

I’m having an issue with using MapImport and the SendCommand function. It seems to get “stuck” after the initial command and won’t execute. Is there a way to run Mapimport from Dynamo?

Looks like you’re missing a closed parenthesis in the file path. Or do you need parenthesis at all since it’s a string already?

Yeah, I noticed that just after posting. I’ve tried with and without parentheses and with /n and \n instead of spaces. It works very well with anything that doesn’t take arguments/parameters but it seems inconsistent when you have to pass things with the commands.

I’ve also tried googling the subject and copy/pasting a few different python snippets with no luck. I also tried loading it into a standalone .lsp to run from Dynamo but I couldn’t get the .lsp script to launch either.

To be clear, mapimport will launch. It just prompts me with a dialogue box every time (even with cmddia and filedia set to 0). -Mapimport avoids the dialoguebox but doesn’t appear to take arguments/parameters from SendCommand.

Any solution that gets a shapefile into Civil3d with object data intact will work just fine for me.

Maybe you could try to modify this for import instead of export.

1 Like

@mzjensen is right. The code should be very similar to the thread he has shared.

Here is a solution for mapimport. I have included the .dyn and a CAD file to test it on to see how it works. You will need to first generate profile files (.ipf) for each shapefile import. Once your import profiles are properly defined you will only need to select the folder of the shapefiles you are importing and the folder of the profile files.

I also zipped up and included the “shapefiles” and “profiles” folders I show in the video. To get to the files you have to remove .txt from the extension in the filename.


MapImportByProfiles.dyn (42.1 KB)
MapImport-V1.dwg (2.7 MB)
MapImport.zip.txt (7.1 KB)

1 Like

Beautiful. Works like a charm and I really like how the strings are formatted like that. I’ll be referencing this any time I have to use SendCommand in the future. Thanks!

1 Like

No worries. To make sure it works how intended you may have to make sure any profile files you name are the same name as the shapefile files and that there are the same number of shapefiles and profiles in each folder since the script is selecting all of the .shp and .ipf files in the folders. This will introduce an issue if you have a folder full of .ipf files but you only want to use a select few. So may have to use a filter in that case. Just fyi!

1 Like

@WrightEngineering I was having some trouble using the SendCommand in a python node, and used yours as inspiration. However, I’m getting an error that says:
System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string
Implying there’s not a running “AutoCAD.Application”, but there is! I was wondering if you might have any insight on how to fix this. Something tells me it has to do with my user rights, but I’m already opening Civil3D (and Dynamo) with admin rights.

1 Like

Hmm, unfortunately I have never ran into that error before so I don’t have much insight.

1 Like

Thank you for replying though, I’ll keep digging :frowning: