AnsweredAssumed Answered

Export Feature Class to CAD

Question asked by hafid1992 on Sep 5, 2014
Latest reply on Sep 5, 2014 by hafid1992

I'm new in Arcobject, and I have to convert a selected features to CAD drawing using just arcobjects and c#.the code below work good when i convert to a shapefile "ShapeFileWorkspaceFactory" but with the "CadWorkspaceFactory" it doesn't work.

any help will be greatly appreciated

 

 

public void featureToCad(){

IFeatureLayer fl = search_layer2(axMapControl1.Map, "parcelle") as IFeatureLayer;


        IFeatureClass pFC;

        IFeatureClassName pInFeatureClassName;
        IDataset pDataset;
        IDatasetName pInDsName;
        IFeatureSelection pFSel;
        ISelectionSet pSelSet;
        IFeatureClassName pFeatureClassName;
        IDatasetName pOutDatasetName;
        IWorkspaceName pWorkspaceName;

        // *******************************
        // Get the featureclass from the layer
        // *******************************
        pFC = fl.FeatureClass;
        // ***********************************************
        // Get the Featureclassname from the featureclass
        // ***********************************************
        pDataset = pFC as IDataset;
        pInFeatureClassName = (IFeatureClassName)pDataset.FullName;
        pInDsName = (IDatasetName)pInFeatureClassName;
        // ***************************
        // Get the selected features
        // ***************************
        pFSel = fl as IFeatureSelection;
        pSelSet = pFSel.SelectionSet;
        IWorkspace pScratchWorkspace;
        IScratchWorkspaceFactory pScratchWorkspaceFactory;
        pScratchWorkspaceFactory = new ScratchWorkspaceFactory();
        pScratchWorkspace = pScratchWorkspaceFactory.DefaultScratchWorkspace;

        // ***************************************************
        // Define the output featureclass
       // give it the name of the input feature class + exp
      // ***************************************************
  pFeatureClassName = (IFeatureClassName)new FeatureClassName();
  pOutDatasetName = (IDatasetName)pFeatureClassName;
  pOutDatasetName.Name = (pFC.AliasName + "exp");
  pWorkspaceName = (IWorkspaceName)new WorkspaceName();
  pWorkspaceName.PathName = "D:\\";
  pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.CadWorkspaceFactory";//it works with "ShapeFileWorkspaceFacto"
  pOutDatasetName.WorkspaceName = pWorkspaceName;
  // *************************************************************
  // Give the output shapefile the same props as the input dataset
  // *************************************************************
  pFeatureClassName.FeatureType = pFC.FeatureType;
  pFeatureClassName.ShapeType = pFC.ShapeType;
  pFeatureClassName.ShapeFieldName = pFC.ShapeFieldName;
  // *************************************************************
  // Export selected features
  // *************************************************************
  pExportOp = new ExportOperation();
  pExportOp.ExportFeatureClass(pInDsName, null, pSelSet, null,pFeatureClassName,0);

Outcomes