The time is too late. directly add the source code:
/// <Summary> // TIN to generate a contour line /// </summary> /// <param name = "pInterval"> contour line spacing </param> public void Tin2Contour (string path _, string name _, double pInterval) {// obtain TIN ITinLayer pTinlayer = GetLayerByName (pScene, comboBox_TIN.Text) as ITinLayer; ITin pTin = pTinlayer. dataset as ITin; // create Contour shape IWorkspaceFactory pWSFac = new ShapefileWorkspaceFactoryClass (); IFeatureWorkspace pFeatureWS = pWSFac. openFromFile (path _, 0) as IFeatureWorkspace; if (System. IO. file. exists (path _ + "\" + name _ + ". shp ") {System. IO. file. delete (path _ + "\" + name _ + ". shp "); System. IO. file. delete (path _ + "\" + name _ + ". dbf "); System. IO. file. delete (path _ + "\" + name _ + ". shx ");} IFields pFields = CreateShapeFields (esriGeometryType. esriGeometryPolyline); pFeatureWS. createFeatureClass (name _, pFields, null, null, esriFeatureType. esriFTSimple, "Shape", null); IFeatureClass pContourFeatureClass = pFeatureWS. openFeatureClass (name _); // generate the contour line ITinSurface pTinSurface = pTin as ITinSurface; pTinSurface. contour (0, pInterval, pContourFeatureClass, "Contour", 0); // Add the Contour layer IFeatureLayer pFeatureLayer = new FeatureLayerClass (); pFeatureLayer. featureClass = pContourFeatureClass; IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer; pGeoFeatureLayer. displayAnnotation = true; pGeoFeatureLayer. displayField = "Contour"; pGeoFeatureLayer. name = pContourFeatureClass. aliasName + "_ Contour"; // set the line style ILineSymbol pLineSymbol = new SimpleLineSymbolClass (); pLineSymbol. color = GetRGBColor (32, 47,247); pLineSymbol. width = 2; ISimpleRenderer pRender = pGeoFeatureLayer. renderer as ISimpleRenderer; pRender. symbol = pLineSymbol as ISymbol; pScene. addLayer (pFeatureLayer as ILayer );}
# Region create a geometric field // <summary> // create a geometric field // </summary> // <param name = "p_esriGeotype"> </param>/ // <returns> </returns> public IFields CreateShapeFields (esriGeometryType p_esriGeotype) {IFields pFields = new FieldsClass (); IFieldsEdit pFieldsEdit = pFields as alias; IGeometryDef pGeoDef = new GeometryDefClass (); IGeometryDefEdit pGeoDefEdit = pGeoDef as alias; pGeoDefEdit. geometryType_2 = p_esriGeotype; pGeoDefEdit. spatialReference_2 = (ISpatialReference) new UnknownCoordinateSystem (); IField peld = new FieldClass (); IFieldEdit pFldEdit = pFld as IFieldEdit; pFldEdit. name_2 = "shape"; pFldEdit. isNullable_2 = false; pFldEdit. type_2 = esriFieldType. esriFieldTypeGeometry; pFldEdit. geometryDef_2 = pGeoDef; pFieldsEdit. addField (pfield); return pFields;} # endregion # region obtain the layer by name // obtain the layer public ILayer GetLayerByName (IScene scene, string strLayerName) {ILayer pLayer = null; for (int I = 0; I <scene. layerCount; I ++) {pLayer = scene. get_Layer (I); if (strLayerName = pLayer. name) {break ;}} return pLayer ;}# endregion
For more information about the Contour function, see the help documentation!