Select to view content in your preferred language

Export Feature Class to CAD

1564
2
09-05-2014 03:08 AM
hafidismaili
Deactivated User

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);
0 Kudos
2 Replies
TimothyHales
Esri Notable Contributor

I've moved your post into the ArcObjects SDK space. You will get a much better answer here as the GeoNet Help is intended for community help and feedback. You can see more on the community structure, and what topics are under each space from the following documents:

GeoNet Community Structure

ArcGIS Discussion Forums Migration Strategy

Thanks!

Timothy

0 Kudos
hafidismaili
Deactivated User

thanks a lot

0 Kudos