<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Geoprocessor - C# - Create empty feature class using template for attribute field in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251857#M6486</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to give the FeatureClass as the argument and not the FeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Translate the template layer into a string (full path) will always work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Other then that there is better way to run GP tools in C# by using the real parameter names. Check this: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/0001/000100000161000000.htm"&gt;http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/0001/000100000161000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have fun&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mody&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Jun 2014 04:05:45 GMT</pubDate>
    <dc:creator>ModyBuchbinder</dc:creator>
    <dc:date>2014-06-18T04:05:45Z</dc:date>
    <item>
      <title>Geoprocessor - C# - Create empty feature class using template for attribute fields</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251856#M6485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the ArcObjects SDK - C# and geoprocessor to create an empty polyline featureclass in a file geodatabase. This feature class will use an existing feature class in the file geodatabase as a template for its' fields. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can get this to work ok using Python, however when I run my C#/ArcObjects code the required fields are not being created from the template. The output created only has the default featureclass attributes - OBJECTID, Shape and Shape_Length.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone point out where I am going wrong? I think I have used the correct syntax ok from ArcGIS Geoprocessing help. The code is shown below. Any help would be much appreciated to solve a frustrating problem!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Barry Mason&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Senior DBA/GIS Developer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPT&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/////////////////////////////////////////////////////////////////////////////////////////&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IWorkspace out_path = workspaceFactory.OpenFromFile(@"C:\ProfLP.gdb", 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)out_path; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string out_name = "outputTest";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;string geometry_type = "POLYLINE";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureLayer pInFeatLayer = new FeatureLayerClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IFeatureClass pInFeatClass = featureWorkspace.OpenFeatureClass("Profile42770");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pInFeatLayer.Name = pInFeatClass.AliasName;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pInFeatLayer.FeatureClass = pInFeatClass;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string has_m = "DISABLED";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;string has_z = "DISABLED";&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;SpatialReferenceEnvironment spatialRefEnv = new SpatialReferenceEnvironmentClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ISpatialReference spatial_reference = (ISpatialReference)spatialRefEnv.CreateProjectedCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRProjCSType.esriSRProjCS_BritishNationalGrid); //OSGB&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;string config_keyword = "";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Double spatial_grid_1 = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Double spatial_grid_2 = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Double spatial_grid_3 = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Create the geoprocessor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IGeoProcessor2 gp = new GeoProcessorClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Create an IVariantArray to hold the parameter values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;IVariantArray parameters = new VarArrayClass();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Populate the variant array with parameter values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(out_path);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(out_name);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(geometry_type);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(pInFeatLayer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(has_m);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(has_z);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameters.Add(spatial_reference);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//parameters.Add(config_keyword);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//parameters.Add(spatial_grid_1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//parameters.Add(spatial_grid_2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//parameters.Add(spatial_grid_3);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;object sev = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Execute the tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Execute("CreateFeatureclass_management", parameters, null);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Console.WriteLine(gp.GetMessages(ref sev));&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;///////////////////////////////////////////////////////////////////////&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The console output is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CreateFeatureclass C:\ProfLP.gdb outputTest POLYLINE Profile42770 DISABLED &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DISABLED "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_O&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;,UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER[&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Centr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;al_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;_Origin',49.0],UNIT['Meter',1.0]];-5220400 -15524400 10000;-100000 10000;-100000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 10000;0.001;0.001;0.001;IsHighPrecision" # 0 0 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Jun 17 11:02:40 2014&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Succeeded at Tue Jun 17 11:02:40 2014 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2014 09:06:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251856#M6485</guid>
      <dc:creator>BarryMason</dc:creator>
      <dc:date>2014-06-17T09:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessor - C# - Create empty feature class using template for attribute field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251857#M6486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to give the FeatureClass as the argument and not the FeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Translate the template layer into a string (full path) will always work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Other then that there is better way to run GP tools in C# by using the real parameter names. Check this: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/0001/000100000161000000.htm"&gt;http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/0001/000100000161000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have fun&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mody&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 04:05:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251857#M6486</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2014-06-18T04:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessor - C# - Create empty feature class using template for attribute field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251858#M6487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As Mody said you can pass your template layer as string because it's a &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_use_multiple_inputs/0001000003m8000000/"&gt;Multi value parameter&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also use &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Members/00470000353t000000/"&gt;ESRI.ArcGIS.DataManagementTools.CreateFeatureclass&lt;/A&gt;&lt;SPAN&gt; which is the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach is to use&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0049000000pz000000"&gt; IfeatureWorkspace.CreateFeatureClass &lt;/A&gt;&lt;SPAN&gt; and pass your fields from Template featureclass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 05:52:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251858#M6487</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2014-06-18T05:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessor - C# - Create empty feature class using template for attribute field</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251859#M6488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Many thanks guys. Passing the template argument in as a string solved the problem. It was confusing because the geoprocessing help said that this argument was a feature layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Barry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2014 06:42:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/geoprocessor-c-create-empty-feature-class-using/m-p/251859#M6488</guid>
      <dc:creator>BarryMason</dc:creator>
      <dc:date>2014-06-18T06:42:47Z</dc:date>
    </item>
  </channel>
</rss>

