0

I use ArcGIS 10.1 & arcobjects.net.

I have the following code:

        ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
        gp.OverwriteOutput = true;

        ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile tool = new ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile();


        tool.Input_Features = @"F:\test buffer of JAMNAGAR SHP FILES ex3\FOOTPATH.dwg";
        tool.Output_Folder = @"C:\Temp1";
        gp.Execute(tool, null);

but after executing this code I got an error

"Error HRESULT E_FAIL has been returned from a call to a COM component. "

If anyone have any suggestion or any sample for this conversion or any link then send me please

  • are you able to convert using arcpy? This would prove that the conversion is possible and the file isn't broken. Does the tool require an output name as well as output folder? – Michael Stimson Apr 1 '14 at 22:00
  • sorry i dont know arccpy?it require only output folder location where all files are stored.if you have sample using arccpy then send me link or having some solution regarding above then it will useful for me. – user26464 Apr 2 '14 at 4:47
  • If not arcpy then toolbox. Search for the geoprocessing tool Feature Class to Shapefile and try to convert manually, this will also give you a good idea of what parameters the object expects to be set, if this fails then the dwg file is broken and no code fixing is going to help. – Michael Stimson Apr 2 '14 at 23:46
  • 1
    Is this a standalone application or an add-in? Standalone applications need an AOInitialize to grab the license. – Michael Stimson Apr 5 '14 at 6:32
  • 1
    look up help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… you need to 'grab' an ESRI license before you do anything important; some objects will work without a license but you can't do anything meaningful until your application is appropriately licensed. – Michael Stimson Apr 5 '14 at 22:29
1

If .dwg files are simalar to .dxf files then part of your problem may be with the parameter you are providing for Input_Features, i.e. the path to your .dwg file.

I perform the same geoprocessing operation ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile on .dxf files. Because the .dxf file contains subsets of data within it (i.e. an annotation layer, geometry layers, etc.) you will need to add the sub dataset name to your path. In my case I have .dxf files that have the following sub datasets:

  • Annotation
  • Multipath
  • Point
  • Polygon
  • Polyline

Although these are contained in the same .dxf file they are essentially different datasets so to export the Point data I would need append Point to the Input_Features parameter to run ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile like this:

//create geoprocessor object, FeatureClassToShapefile object, and set input parameters
ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = New ESRI.ArcGIS.Geoprocessor.Geoprocessor();
ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile FCToShapeFile = new ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile();
FCToShapeFile.Input_Features = "C:\CAD_to_Shp\temp.dxf\Point"; //appended Point to the path to input features
FCToShapeFile.Output_Folder = "C:\CAD_to_Shp\";

//run geoprocessor operation
GP.Execute(FCToShapeFile, null);

**Because this is a standalone application make sure you have taken the steps that @MichaelMiles-Stimson has suggested to initialize the ESRI license.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.