Basics of arc objects

877
10
11-19-2010 08:54 PM
MuraliPandey
New Contributor
Hi,

How do i create a Fillegeodatabase + import features(say point,line,polygon) from that using C#
If somebody have sample(simple) code then it will b best...


Thanks
0 Kudos
10 Replies
RuchiraWelikala
Occasional Contributor
Hi,

How do i create a Fillegeodatabase + import features(say point,line,polygon) from that using C#
If somebody have sample(simple) code then it will b best...


Thanks


http://edndoc.esri.com/arcobjects/9.2/NET/fde31db0-af15-409f-81b5-75c23d4a762e.htm#CreateFGDB
0 Kudos
MuraliPandey
New Contributor
http://edndoc.esri.com/arcobjects/9.2/NET/fde31db0-af15-409f-81b5-75c23d4a762e.htm#CreateFGDB



Thanks for ur kind response.

Actually , I m a beginnar of arc objects (as reflected by my questions).
In addition to the above ,I m looking for sample exe application(Hello World Type in c#).
0 Kudos
Venkata_RaoTammineni
Occasional Contributor
hi,

  Please find the complete code... what you looking

private static void ExportShapefiles(string strFolderPath)
       {
           try
           {
               IWorkspaceName pWorkspaceName;

               IFeatureClassName pFeatClassName;

               IDatasetName pDataSetName;

               //define the wrokpace

               pWorkspaceName = new WorkspaceNameClass();

               pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory";

               CreateAccessWorkspace(@"C:\temp\");

               pWorkspaceName.PathName = strFolderPath;

               //Define the dataset.
               pFeatClassName = new FeatureClassNameClass();

               pDataSetName = pFeatClassName as IDatasetName;

               pDataSetName.WorkspaceName = pWorkspaceName;

               pDataSetName.Name = "Export_Data";

               IWorkspaceName pInShpWorkspaceName;

               IFeatureClassName pFCName;

               IDatasetName pShpDatasetName;

               //Define the workspace.

               pInShpWorkspaceName = new WorkspaceNameClass();

               pInShpWorkspaceName.PathName = @"D:\Temp\Pro\Sample\Sample";

               pInShpWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";

               //Define the dataset.

               pFCName = new FeatureClassNameClass();

               pShpDatasetName = pFCName as IDatasetName;

               pShpDatasetName.Name = "polygon.shp";

               pShpDatasetName.WorkspaceName = pInShpWorkspaceName;

               IFeatureDataConverter pShpToFC;
           
               pShpToFC = new FeatureDataConverterClass();

               pShpToFC.ConvertFeatureClass(pFCName, null, null, pFeatClassName, null, null, "", 1000, 0);

               MessageBox.Show ("Shapefile conversion complete!");

           }
           catch (Exception exp) { }

       }
   

       public static void CreateAccessWorkspace(String path)
       {
           try
           {
               // Instantiate an Access workspace factory and create a personal geodatabase.
               // The Create method returns a workspace name object.

               Type factoryType = Type.GetTypeFromProgID(
                 "esriDataSourcesGDB.AccessWorkspaceFactory");
               IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)
                 Activator.CreateInstance(factoryType);
               IWorkspaceName workspaceName = workspaceFactory.Create(path, "Sample.mdb",
                 null, 0);

               // Cast the workspace name object to the IName interface and open the workspace.
               IName name = (IName)workspaceName;
               IWorkspace workspace = (IWorkspace)name.Open();

               MessageBox.Show("Geo Database Just Created", "Data Creator");
           }
           catch (Exception exp) { }
       }

Thanks and Regards,

Venkat Tammineni
0 Kudos
MuraliPandey
New Contributor
Thanks Venkat.....!!
It will help me a lot....!!
0 Kudos
Venkata_RaoTammineni
Occasional Contributor
Your welcome.......
0 Kudos
MuraliPandey
New Contributor
Hi
please tell me  ,how should I proceed on learning arc objects (C#)...!!
0 Kudos
Venkata_RaoTammineni
Occasional Contributor
Hi
please tell me  ,how should I proceed on learning arc objects (C#)...!!


Do you have C# knowledge ?
0 Kudos
MuraliPandey
New Contributor
I m working in C++ ..
and little bit experience in C#.....

I want to start Arc ob..   in C# .....
0 Kudos
Venkata_RaoTammineni
Occasional Contributor
I m working in C++ ..
and little bit experience in C#.....

I want to start Arc ob..   in C# .....


Hi,


You need to learn first .NET...then you can easily work with arcobjects .net...


Thanks and Regards,

Venkat
0 Kudos