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: 

Civil3D pipe Road Data to SDF (GIS) Export using .NET C#

10 REPLIES 10
Reply
Message 1 of 11
raghulan
1159 Views, 10 Replies

Civil3D pipe Road Data to SDF (GIS) Export using .NET C#

Hello Ppl, 

 

 I have this issue, 

I want to export civil3D pipe, road, alignment as SDF file with additional properties.

currently civilSDF Export option only has limited options for exporting for civil 3D objects.

 

Basically I am developing an app It would export selected feature(eg: pipe) with all available properties such as material, radius, etc.

 

I tried an example online - which showed how to create SDF file and fetch data from layers. which is not usefull in my case.

 

I want to do exactly like the civilsdf export tool with additional properties can be selected.

 

if anyone help me with, how I can get geometry data of pipes or an exmple atleast that would be great.

 

Thanks guys.!

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
10 REPLIES 10
Message 2 of 11
andrewpuller3811
in reply to: raghulan

have a look at the infrastructure dev blog here-

 

http://adndevblog.typepad.com/infrastructure/

 

There are a few examples of working with civil 3d objects.



If a post provides a fix for your issue, click on "Accept as Solution" to help other users find solutions to problems they might have that are similar to yours.

Andrew Puller
Maitland, NSW, Australia
Windows 10 Enterprise 64bit
Intel core i7 11800 @ 2.30 GHz with 32GB Ram
Civil 3d 2021
Message 3 of 11
raghulan
in reply to: raghulan

Thanks for the reply. but I couldnt find anything relavent to pipes in there.

If there is any code snippet that would be great.

 

Cheers

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 4 of 11

Check out:

C:\Program Files\Autodesk\AutoCAD Civil 3D 2013\Sample\Civil 3D API\DotNet\CSharp\PipeDataExcel\PipeDataExcel.cs

 

Christopher

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 5 of 11

I cheked it but it doesnt give anywhere for getting geometry of the pipes.

Is there any example on how to get the geometry of the pipe or create gemetry data of pipes to be stored in an SDF file from the start and end point of the point.

 

Cheers

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 6 of 11
Partha.Sarkar
in reply to: raghulan

I don't see any API available to export Civil 3D objects other than using the ExportToSDF  command (Export Civil Objects to SDF).

 

This UI command exports the Geometry and some other useful attributes like - InsideDia, OtsideDia, Length, slope etc.

 

Once the SDF is connected using FDO provider you can use the Expression builder and use the "Geometry" property to create a custom calculation.

 

Does it help ?



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 7 of 11
raghulan
in reply to: raghulan

Thank Partha for the info.

Now I changed the course ...I am creating the SDF using the standard tool from C3D and then I wrote some code to create additional property defnitions under each featureclass..

 

then another code to insert/update value to the appropriate property defnition.

 

I am stuck at the point where my code to insert/ udpate doesnt seem to work.

 

Is there any example for code sinpet in C# to insert/ update value to the desiered coloumn and row in a feature class.

 

While inserting/ updating i want the code to choose the appropriate feature class (eg: pipe) and then column or property defnition (eg: lets say associated surface - custom added property - string data type) and check the pipe name (row) and add value.!!

 

please assist.

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 8 of 11
Partha.Sarkar
in reply to: raghulan

Is there any example for code sinpet in C# to insert/ update value to the desiered coloumn and row in a feature class.

 

>>> Did you check the following blog post ?


http://adndevblog.typepad.com/infrastructure/2012/05/how-to-modify-update-feature-attribute-using-ap...

 

Does it help ?



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 9 of 11
raghulan
in reply to: Partha.Sarkar

Partha, 

 

 I checked that, my code is derived from that one and other the MAP3D developer Guide example and anothero one I found from OSGEO documentation.

 

But the problem is the code explains how to insert update data located in a layer.

in my case I have a SDF file and the SDF file I have feature classes (pipes, roads, alignments, etc) with that I have property defnitions (id, radious, starting point ,etc)

also there may be multiple pipes available (P1, P2, p3)

 

Now I want to go in to the desired feature class (eg: pipe)

then to the appropriate property defnition(eg: Associated surface - which already created in the schema)

and then I have go the row (pipe - p2) and update the value of the Associated surface for pipe p2 to the desiered value...

 

Any help would be appreciated. !!

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 10 of 11
raghulan
in reply to: Partha.Sarkar

some more information

===================

 

My schema Structure (SDF File) 
==================================================== 
Schema name: Civil_schema 
Feature classes : Pipes, structure, point, ... 
properties inside Pipes feature class : PipeRadius, PipeType,.... 

==================================================== 
Now that I have the schema, I have two pipe data inside (two rows - PipeName = p1 and p2) 
I want to insert PipeType as Iron for R-1P1 and PVC for R-1P2 

for some reason my insert and update command isnt working... 


Code snippet 
==================================================== 

//static sdf file 
string sdffile = "c:\test.sdf"; 

//created a IConnection con (i have this in correct - just dont want to write all) 

using(con) 

    using (osgeo_command.Feature.IUpdate update_data =                 con.CreateCommand(osgeo_command.CommandType.CommandType_Update) as osgeo_command.Feature.IUpdate) 
       { 
            //set the target schema 
            update_data.SetFeatureClassName("Civil_schema: Pipes"); //schema name:clas name = this worked for reading 
            update_data.SetFilter("Name = R-1P1"); // this is to identify the row - i am not going to update this row 

            // property value collection 
            PropertyValueCollection pcoll = update_data.PropertyValues; 

            //creating a property value that needs to be added 
             PropertyValue propvalue = null; 
             propvalue = new PropertyValue(); 

             ValueExpression expression = (ValueExpression)Expression.Parse("'Iron'"); //want to add iron as my pipe type 

            propvalue = new PropertyValue("Pipetype", expression);//here i am specifying the column name as Pipetype 

            pcoll.Add(propvalue); 

             if (1 != update_data.Execute()) 
                    { 
                        ed.WriteMessage("\nUpdate failed");//this writes the message in autocad 
                    } 

       } 


============================================================== 
I dont know where i am going wrong...could you guys point me the correct direction please.. 

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 11 of 11
ralstogj
in reply to: raghulan

Guys

 

Were you able to get this code to work I have a similar situation here where I am trying to get an automated workflow up and running to supply shp data to the local council in their format.

 

Currently I have

1. Some code to update my design pipe network with updated as built survey data.

2. Then I am using the workflow described here to convert the Civil3d objects to a sdf file and then make shp files

http://www.augi.com/library/convert-civil-3d-data-to-shp-files

3. The problem after getting to this point is I have to add a number of addintional fields of data that do not come into the sdf file from the Civil3d model for example pipe material,manufacturer and other fields required to meet councils format such as pipe condition, install date, etc. I do not know how to do this by hand yet but would ultimately like to do it with code if possible.

 

As my problem sounds similar to yours I thought I would ask to see it you found a solution. Before I look at it indepth myself.

 

 

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/

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

Post to forums  

Rail Community


Autodesk Design & Make Report