This document is archived and information here might be outdated.  Recommended version.


How to work with IExtrude (ArcObjects .NET 10.5 SDK)

How to work with IExtrude


In this topic


About working with IExtrude

This topic shows how to use the IExtrude interface and associated methods. The following code example shows how to use IExtrude:
[C#]
private void IExtrude_Example()
{
    //Create a geometry environment object.
    IExtrude extrude=new GeometryEnvironmentClass();
[VB.NET]
Sub IExtrude_Example()
    Dim pExtrude As IExtrude, pOutGeometry As IGeometry
    Dim pBaseGeometry As IGeometry, pExtrusionLine As ILine
    Dim pExtrusionVector As IVector3D
    'Create a geometry environment object.
    pExtrude=New GeometryEnvironment

Calling the Extrude method

Do the following steps to call the Extrude method:
  1. Create a base geometry.
  2. Given an offset distance, call Extrude.

    See the following code example:
[C#]
//************************************
//** Extrude
//************************************
//Point example.
IGeometry baseGeometry=CreatePoint()as IGeometry;
IGeometry outGeometry=extrude.Extrude(100, baseGeometry);
System.Windows.Forms.MessageBox.Show("Extrude \n Output Geometry Type : " +
    outGeometry.GeometryType);
//Polygon example.
baseGeometry=CreatePolygon()as IGeometry;
outGeometry=extrude.Extrude(100, baseGeometry);
System.Windows.Forms.MessageBox.Show("Extrude \n Output Geometry Type : " +
    outGeometry.GeometryType);
[VB.NET]
'************************************
'** Extrude
'************************************
Debug.Print("********* Extrude *********")
'Point example.
pBaseGeometry=CreatePoint
pOutGeometry=pExtrude.Extrude(100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)
'Polygon example.
pBaseGeometry=CreatePolygon
pOutGeometry=pExtrude.Extrude(100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)

Calling the ExtrudeAbsolute method

Do the following steps to call the ExtrudeAbsolute method:
  1. Create a base geometry.
  2. Given a uniform input Z, call ExtrudeAbsolute.

    See the following code example:
[C#]
//************************************
//** ExtrudeAbsolute
//************************************
//Point example.
baseGeometry=CreatePoint()as IGeometry;
outGeometry=extrude.ExtrudeAbsolute(100, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeAbsolute \n Output Geometry Type : " +
    outGeometry.GeometryType);
//Polygon example.
baseGeometry=CreatePolygon()as IGeometry;
outGeometry=extrude.ExtrudeAbsolute(100, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeAbsolute \n Output Geometry Type : " +
    outGeometry.GeometryType);
[VB.NET]
'************************************
'** ExtrudeAbsolute
'************************************
Debug.Print("********* ExtrudeAbsolute *********")
'Point example.
pBaseGeometry=CreatePoint
pOutGeometry=pExtrude.ExtrudeAbsolute(100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)
'Polygon example.
pBaseGeometry=CreatePolygon
pOutGeometry=pExtrude.ExtrudeAbsolute(100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)

Calling the ExtrudeAlongLine method

Do the following steps to call the ExtrudeAlongLine method:
  1. Create a line as an axis.
  2. Create a base geometry.
  3. Call ExtrudeAlongLine.

    See the following code example:
[C#]
//************************************
//** ExtrudeAlongLine
//************************************
ILine extrusionLine=CreateExtrusionLine();
//Point example.
baseGeometry=CreatePoint()as IGeometry;
outGeometry=extrude.ExtrudeAlongLine(extrusionLine, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeAlongLine \n Output Geometry Type : " +
    outGeometry.GeometryType);
//Polygon example.
baseGeometry=CreatePolygon()as IGeometry;
outGeometry=extrude.ExtrudeAlongLine(extrusionLine, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeAlongLine \n Output Geometry Type : " +
    outGeometry.GeometryType);
[VB.NET]
'************************************
'** ExtrudeAlongLine
'************************************
Debug.Print("********* ExtrudeAlongLine *********")
pExtrusionLine=CreateExtrusionLine
'Point example.
pBaseGeometry=CreatePoint
pOutGeometry=pExtrude.ExtrudeAlongLine(pExtrusionLine, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)
'Polygon example.
pBaseGeometry=CreatePolygon
pOutGeometry=pExtrude.ExtrudeAlongLine(pExtrusionLine, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)

Calling the ExtrudeFromTo method

Do the following steps to call the ExtrudeFromTo method:
  1. Create a base geometry.
  2. Given a from Z and a to Z, call ExtrudeFromTo on the geometry.

    See the following code example:
[C#]
//************************************
//** ExtrudeFromTo
//************************************
//Point example.
baseGeometry=CreatePoint()as IGeometry;
outGeometry=extrude.ExtrudeFromTo(0, 100, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeFromTo \n Output Geometry Type : " +
    outGeometry.GeometryType);
//Polygon example.
baseGeometry=CreatePolygon()as IGeometry;
outGeometry=extrude.ExtrudeFromTo(0, 100, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeFromTo \n Output Geometry Type : " +
    outGeometry.GeometryType);
[VB.NET]
'************************************
'** ExtrudeFromTo
'************************************
Debug.Print("********* ExtrudeFromTo *********")
'Point example.
pBaseGeometry=CreatePoint
pOutGeometry=pExtrude.ExtrudeFromTo(0, 100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)
'Polygon example.
pBaseGeometry=CreatePolygon
pOutGeometry=pExtrude.ExtrudeFromTo(0, 100, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)

Calling the ExtrudeRelative method

Do the following steps to call the ExtrudeRelative method:
  1. Define a three-dimension (3D) vector.
  2. Create a base geometry.
  3. Call ExtrudeRelative to extrude the base geometry along the 3D vector.

    See the following code example:
[C#]
//************************************
//** ExtrudeRelative
//************************************
//Point example.
IVector3D extrusionVector=CreateExtrusionVector();
baseGeometry=CreatePoint()as IGeometry;
outGeometry=extrude.ExtrudeRelative(extrusionVector, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeRelative \n Output Geometry Type : " +
    outGeometry.GeometryType);
//Polygon example.
baseGeometry=CreatePolygon()as IGeometry;
outGeometry=extrude.ExtrudeRelative(extrusionVector, baseGeometry);
System.Windows.Forms.MessageBox.Show("ExtrudeRelative \n Output Geometry Type : " +
    outGeometry.GeometryType);
}
[VB.NET]
'************************************
'** ExtrudeRelative
'************************************
Debug.Print("********* ExtrudeRelative *********")
'Point example.
pExtrusionVector=CreateExtrusionVector
pBaseGeometry=CreatePoint
pOutGeometry=pExtrude.ExtrudeRelative(pExtrusionVector, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)
'Polygon example.
pBaseGeometry=CreatePolygon
pOutGeometry=pExtrude.ExtrudeRelative(pExtrusionVector, pBaseGeometry)
Debug.Print("Output Geometry Type : " & pOutGeometry.GeometryType)

End Sub
The following code example contains some utility functions previously used:
[C#]
//Create the extrusion lie to use in ExtrudeAlongLine.
private ILine CreateExtrusionLine()
{
    ILine line=new LineClass();
    IPoint point0=new PointClass();
    point0.PutCoords(0, 0);
    point0.Z=0;
    IPoint point1=new PointClass();
    point1.PutCoords(0, 0);
    point1.Z=100;
    line.PutCoords(point0, point1);
    return line;
}

//Create the 3D vector to be used in ExtrudeRelative.
private IVector3D CreateExtrusionVector()
{
    IVector3D vector3D=new Vector3DClass();
    vector3D.SetComponents(0, 0, 100);
    return vector3D;
}

private IPoint CreatePoint()
{
    //Point example.
    IPoint point=new PointClass();
    point.PutCoords(100, 100);
    point.Z=0;
    return point;
}

//Create a polygon for the example.
private IPolygon CreatePolygon()
{
    //Create 5 points.
    IPoint[] points=new IPoint[5];
    for (int i=0; i < 5; i++)
    {
        points[i]=new PointClass();
    }
    points[0].PutCoords(0, 0);
    points[0].Z=0;
    points[1].PutCoords(0, 100);
    points[1].Z=10;
    points[2].PutCoords(100, 100);
    points[2].Z=20;
    points[3].PutCoords(100, 0);
    points[3].Z=30;
    points[4].PutCoords(0, 0);
    points[4].Z=0;
    //Create a polygon object.
    IPointCollection4 polygon=new PolygonClass();
    IZAware zAware=polygon as IZAware;
    //The polygon Zs aware.
    zAware.ZAware=true;
    //Add the points to the polygon because
    //IPointCollection.AddPoints uses non C# C-Style Arrays; however, use IGeometryBridge.
    IGeometryBridge geometryBridge=new GeometryEnvironmentClass();
    geometryBridge.AddPoints(polygon, ref points);
    ITopologicalOperator topologicalOperator=polygon as ITopologicalOperator;
    topologicalOperator.Simplify();
    return polygon as IPolygon;
}
[VB.NET]
'Create the extrusion lie to use in ExtrudeAlongLine.

Private Function CreateExtrusionLine() As ILine
    Dim pLine As ILine
    Dim pt0 As IPoint, pt1 As IPoint
    pLine=New Line
    pt0=New Point
    pt0.PutCoords(0, 0)
    pt0.Z=0
    pt1=New Point
    pt1.PutCoords(0, 0)
    pt1.Z=100
    pLine.PutCoords(pt0, pt1)
    CreateExtrusionLine=pLine
End Function

'Create the 3D vector to be used in ExtrudeRelative.

Private Function CreateExtrusionVector() As IVector3D
    Dim pVector3D As IVector3D
    pVector3D=New Vector3D
    pVector3D.SetComponents(0, 0, 100)
    CreateExtrusionVector=pVector3D
End Function


Private Function CreatePoint() As IPoint
    'Point example.
    Dim pPoint As IPoint
    pPoint=New Point
    pPoint.PutCoords(100, 100)
    pPoint.Z=0
    CreatePoint=pPoint
End Function

'Create a polygon for the example.

Private Function CreatePolygon() As IPolygon
    Dim pPoint1(4) As IPoint, pPolygon As IPointCollection
    Dim pZaware As IZAware, pTopoOp As ITopologicalOperator
    Dim i As Long
    'Create 5 points.
    For i=0 To 4
        pPoint1(i)=New Point
    Next
    pPoint1(0)=New Point
    pPoint1(0).PutCoords(0, 0)
    pPoint1(0).Z=0
    pPoint1(1)=New Point
    pPoint1(1).PutCoords(0, 100)
    pPoint1(1).Z=10
    pPoint1(2)=New Point
    pPoint1(2).PutCoords(100, 100)
    pPoint1(2).Z=20
    pPoint1(3)=New Point
    pPoint1(3).PutCoords(100, 0)
    pPoint1(3).Z=30
    pPoint1(3)=New Point
    pPoint1(4).PutCoords(0, 0)
    pPoint1(4).Z=0
    'Create a polygon object.
    pPolygon=New Polygon
    pZaware=pPolygon
    'Set the polygon Zs aware.
    pZaware.ZAware=True
    'Add the points to the polygon.
    pPolygon.AddPoints(5, pPoint1(0))
    pTopoOp=pPolygon
    pTopoOp.Simplify()
    CreatePolygon=pPolygon
End Function






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):

Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine