ExportCAD tool - in_features field

2549
2
08-11-2011 04:44 AM
RodrigoSalvador
New Contributor
Hi all

I'm trying to export some features do CAD using C#. When I set the in_features field with an absolut path, like "C:\temp.shp" or "C:\geodatabase.sde\DB.layer\DB.sublayer", it works fine. But if I try to set as a reference, like the following code, it doesn't export anything (but doesn't throw exceptions either):

        List<IFeatureClass> lFeatClass = null;
        IFeatureClass pFeatClass = null;
        FeatureClass pFeatureClass = null;
        //IFeatureLayer pFeatLayer;         
 
          lFeatClass = this.getAllFeatureClasses(); 
          //pFeatLayer = new FeatureLayerClass();
          for (int iFeat = 0; iFeat < lFeatClass.Count; iFeat++)
          {
             pFeatClass = lFeatClass[iFeat];
             pFeatureClass = (FeatureClass)pFeatClass;

             //pExportCAD.in_features = pFeatClass;
             pExportCAD.in_features = pFeatureClass; // this field which I'm asking for help

             strOutFile = strOutFile.Split('.')[0] + "_" + lFeatClass[iFeat].AliasName.ToUpper() + "." + strOutFile.Split('.')[1];
             pExportCAD.Output_File = strOutFile;
             pExportCAD.Output_Type = strOutType; 

             if (pGP.Exists(pExportCAD.in_features, ref obj))
             {
               pResults = (IGeoProcessorResult)pGP.Execute(pExportCAD, null);
             }
         }



Does anyone know why can't I pass the Feature Class, or even the Feature Layer, as reference? Does it work if I set a .gdb as input, instead of feature class?

Thanks in advance
0 Kudos
2 Replies
RodrigoSalvador
New Contributor
Hi again

I'm still looking for answers here. Meanwhile, another idea I've got is to convert all data I want to a export to a temporary shapefile, and export this one. I'm start researching, but any tips, and also answers for the first question, will be very helpful.

Thanks in advance

Rodrigo Salvador
0 Kudos
RodrigoSalvador
New Contributor
Hi. I found a solution, and I'll post here for future searchs.

The in_features field realy do not accept references. The best I've got is to set the path, not absolute, but dinamic. I found the path to the Feature Classes using ArcCatalog, and the final product looks like this:

          pFeatClass = lFeatClass[iFeat];
          pFeatureClass = (FeatureClass)pFeatClass ;
          pWorkspace = pFeatureClass.Workspace;
          string wksp = pWorkspace.PathName + @"\DBLayer\" + pFeatureClass.Name;

          pExportCAD.in_features = wksp;


(I was not able to set "DBLayer" in dinamic mode, but in my case, it's the main group layer, the only one I need).

If someone's wonder to base a code on this, please pay attention, because I'm having troubles with memory, some sort of Stack Overflow. Not sure if it comes from this part of the code or another, but it's definitely coming from the export method.

Hope it helps.

Rodrigo Salvador
0 Kudos