AnsweredAssumed Answered

ArcObjects 10.1, C#, export "Create Steepest Path" output to shapefile

Question asked by jaeckli on Oct 15, 2013
Latest reply on Oct 16, 2013 by jaeckli
Hi
I'm using ArcObjects 10.1 and C# and would like to export the result of the "Create Steepest Path" Tool into a new Shapefile or FeatureClass. I thought that the result of the "Create Steepest Path" Tool is a graphic line which will be stored in ArcMap (ActiveGraphicsLayer). After executing the "Create Steepest Path" Tool a graphic line is created and displayed but the ActiveGraphicsLayer seems to be empty. pElement in the code below, which should contain the graphic line, is empty. Any suggestion?

       // Umwandlung Graphik-Linie in 3D Shape
        public void ConvertGraphicTo3DShape(string aName, string aPath, ESRI.ArcGIS.Carto.IActiveView pActiveView)
        {
            ...

            // Shape WorkspaceFactory
            ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWSF =
                new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();

            // Workspace
            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace pFWS =
                (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)pWSF.OpenFromFile(StrOutPath,0);
           
            // Geometry Typ
            ESRI.ArcGIS.Geometry.esriGeometryType pGeomType =
                esriGeometryType.esriGeometryPolyline;

            // Shape-Datei anlegen (Methode "CreateShape" aus Klasse "CreateShapeFile")
            CreateShapeFile pShape = new CreateShapeFile();
            ESRI.ArcGIS.Geodatabase.IFeatureClass pOutFC =
                pShape.CreateShape(pFWS, aPath, aName, pGeomType, null);

            // Feature Cursor
            ESRI.ArcGIS.Geodatabase.FeatureCursor pFCur =
                (ESRI.ArcGIS.Geodatabase.FeatureCursor)pOutFC.Insert(true);

            // Memory Buffer
            ESRI.ArcGIS.Geodatabase.IFeatureBuffer pFBuff =
                (ESRI.ArcGIS.Geodatabase.IFeatureBuffer)pOutFC.CreateFeatureBuffer();

            // Aktive Karte
            ESRI.ArcGIS.Carto.IMap pMxMap = pActiveView.FocusMap;

            // Graphic Container
            //ESRI.ArcGIS.Carto.IGraphicsContainer pGC = pActiveView.GraphicsContainer;
            ESRI.ArcGIS.Carto.IGraphicsContainer pGC =
                (ESRI.ArcGIS.Carto.IGraphicsContainer)pMxMap;
           
            // Polyline Grafikelemente in die Shape-Datei schreiben
            ESRI.ArcGIS.Carto.IElement pElement =
                (ESRI.ArcGIS.Carto.IElement)pGC.Next();

            while (!(pElement == null))
            {
                if (pElement.Geometry.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                {
                    pFBuff.Shape = pElement.Geometry;
                    pFCur.InsertRow(pFBuff);
                }
                pElement = pGC.Next();
            }
            pFCur.Flush();

            ...
       }

Thank you for your help.
Martin

Outcomes