Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a SHP file in code?

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Jeff_M
1655 Views, 9 Replies

Create a SHP file in code?

I searched the Map3d customization forum and couldn't find anything on this. Hoping someone here can lend a hand. I have c# code which creates AutoCAD DBPoints and attaches ObjectData to them. There are other objects in the dwg, but I'm only interested in the Points. I now want to export a SHP file of those points with OD so they can be imported into a GIS database by others.

 

Looking through the Autodesk.Gis.Map.ImportExport namespace, I'm just not seeing what needs to be done to accomplish this task. Any suggestions, pointers, links to blogs, etc. would be welcomed.

Jeff_M, also a frequent Swamper
EESignature
9 REPLIES 9
Message 2 of 10
norman.yuan
in reply to: Jeff_M

Jeff,

 

Yes, you looked into the correct place: Autodesk.Gis.Map.ImportExport namespace. All the APIs in this namespace do exactly the same as Acad Map's MapImport/Export commands. Manually run the Acad Map built-in command certainly helps to understand more on the APIs.

 

You can also download AutoCAD MAP ObjectARX SDK (not to be confused with AutoCAD ObjectARX SDK), which comes with .NET API sample code, including a sample project of Map importing/exporting.

 

I know you probably will do it in .NET code. But if LISP solution is suitable, you can do it with a few lines of lisp code: Do the manual importing/exporting command; but instead of "OK" the dialog, you can save the manually built importing/exporting configuration as profile and use LISP (command...) to drive the profile). Also, the import/export profile is actual XML file. Browsing its content also helps to using import/export API.

 

Another more complicated method would be to use AutoCAD Map GIS platform API (FDO) to convert the point as FDO feature point and save them to shape (FDO source). You probably only want to look into this if the drawing has/needs FDO data connection.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 10
tyronebk
in reply to: Jeff_M

I wrote a command to export structures and pipes to SHP a while ago (the ExportToSDF command does not properly handle curved pipes, it draws them as straight lines end to end). I think this blog pointed me in the right direction. I'm happy to share some of my code if you run into any road blocks.

 

Message 4 of 10
Jeff_M
in reply to: tyronebk

Thanks, @tyronebk, exactly what I was looking for.

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 10
Jeff_M
in reply to: Jeff_M

Thanks to @norman.yuan and @tyronebk for pointing me in the right direction. I now have my code working almost exactly how it needs to. The only snag I've hit is in the exported ObjectData names. When I export manually in Map3D the exported column names are exactly as shown in the Mappings dialog. I can successfully create the Mappings in code, verify they are exactly what I need as I step through in Debug mode, yet when I Export() the shp file the Column names are all truncated to 10 characters. I did a search in the Map3d customization forum and found nothing related to this, and the Developer docs for Map don't mention there being a limitation on the length of the names.

 

Has anyone else seen this? Is there a setting I missed to allow longer names?

Jeff_M, also a frequent Swamper
EESignature
Message 6 of 10
tyronebk
in reply to: Jeff_M

I believe the 10 character limit is defined in the SHP standard. If you export objects and properties using MAPEXPORT, and the field header is longer than 10 characters, it is also truncated. It also happens if you bulk copy from an SDF to SHP.

 

Example:

mapexport.png

 

How are you exporting in Map 3D and retaining the header length?

Message 7 of 10
Jeff_M
in reply to: tyronebk

Well, evidently I was looking at something that wasn't there. I am now seeing the same 10 character limit using MapExport & MapImport. Thanks for the response and wake up call.
Jeff_M, also a frequent Swamper
EESignature
Message 8 of 10
Jeff_M
in reply to: Jeff_M

For anyone else following along and curious about the 10 character limit, I found this:

http://resources.arcgis.com/en/help/main/10.1/index.html#/by_adding_a_field_in_ArcCatalog/0056000000...

Jeff_M, also a frequent Swamper
EESignature
Message 9 of 10
Anonymous
in reply to: Jeff_M

I need to do the same thing with AutoCAD and ObjectARXSDK not AutoCAD Map, is there any library that can help me coding that ?? 

Message 10 of 10
Civil3DReminders_com
in reply to: Anonymous

http://shapelib.maptools.org/

shapelib.dll

 

You'll need to download the source code and recompile for 64-bit.

 

There is also this that is more maintained, but I haven't had a chance to use the code.

http://qgis.org/en/site/

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report