ArcObjects Library Reference  

ElementUtilities

About the 3D multipatch examples Sample

[C#]

ElementUtilities.cs

using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Analyst3D;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;

namespace MultiPatchExamples
{
    public static class ElementUtilities
    {
        private const double HighResolution = 1;
        private const esriUnits Units = esriUnits.esriUnknownUnits;

        public static IElement ConstructPolylineElement(IGeometry geometry, IColor color, esriSimple3DLineStyle style, double width)
        {
            ISimpleLine3DSymbol simpleLine3DSymbol = new SimpleLine3DSymbolClass();
            simpleLine3DSymbol.Style = style;
            simpleLine3DSymbol.ResolutionQuality = HighResolution;

            ILineSymbol lineSymbol = simpleLine3DSymbol as ILineSymbol;
            lineSymbol.Color = color;
            lineSymbol.Width = width;

            ILine3DPlacement line3DPlacement = lineSymbol as ILine3DPlacement;
            line3DPlacement.Units = Units;

            ILineElement lineElement = new LineElementClass();
            lineElement.Symbol = lineSymbol;

            IElement element = lineElement as IElement;
            element.Geometry = geometry;

            return element;
        }

        public static IElement ConstructMultiPatchElement(IGeometry geometry, IColor color)
        {
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Color = color;

            IElement element = new MultiPatchElementClass();
            element.Geometry = geometry;

            IFillShapeElement fillShapeElement = element as IFillShapeElement;
            fillShapeElement.Symbol = simpleFillSymbol;

            return element;
        }
    }
}
[Visual Basic .NET]

ElementUtilities.vb

Imports Microsoft.VisualBasic
Imports System
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Analyst3D
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.esriSystem


Public Class ElementUtilities
    Private Const HighResolution As Double = 1
    Private Const Units As esriUnits = esriUnits.esriUnknownUnits

    Private Sub New()
    End Sub
    Public Shared Function ConstructPolylineElement(ByVal geometry As IGeometry, ByVal color As IColor, ByVal style As esriSimple3DLineStyle, ByVal width As Double) As IElement
        Dim simpleLine3DSymbol As ISimpleLine3DSymbol = New SimpleLine3DSymbolClass()
        simpleLine3DSymbol.Style = style
        simpleLine3DSymbol.ResolutionQuality = HighResolution

        Dim lineSymbol As ILineSymbol = TryCast(simpleLine3DSymbol, ILineSymbol)
        lineSymbol.Color = color
        lineSymbol.Width = width

        Dim line3DPlacement As ILine3DPlacement = TryCast(lineSymbol, ILine3DPlacement)
        line3DPlacement.Units = Units

        Dim lineElement As ILineElement = New LineElementClass()
        lineElement.Symbol = lineSymbol

        Dim element As IElement = TryCast(lineElement, IElement)
        element.Geometry = geometry

        Return element
    End Function

    Public Shared Function ConstructMultiPatchElement(ByVal geometry As IGeometry, ByVal color As IColor) As IElement
        Dim simpleFillSymbol As ISimpleFillSymbol = New SimpleFillSymbolClass()
        simpleFillSymbol.Color = color

        Dim element As IElement = New MultiPatchElementClass()
        element.Geometry = geometry

        Dim fillShapeElement As IFillShapeElement = TryCast(element, IFillShapeElement)
        fillShapeElement.Symbol = simpleFillSymbol

        Return element
    End Function
End Class