FAQ
Bridge インターフェイスの利用

ナレッジ番号:2682 | 登録日:2023/05/29 | 更新日:2023/12/28

概要

ArcObjects のインターフェイスの中には、IGeometryCollection、ISegmentCollection、IPointCollection のメソッドの一部などで、引数として C スタイルの配列を使用しているメソッドがあります。これらは一部の言語環境ではサポートされていませんが、代わりにセーフ配列を使用する IGeometryBridge インターフェイスを使用することでこの問題を解決しています。メソッドの説明で、IGeometryBridge(またはIGeometryBridge2)インターフェイスを使うように示されている場合は IGeometryBridge2 インターフェイスを使用しなければなりません。

対象となるインターフェイスとメソッドは下記ページのトピックを参照してください。

Using IGeometryBridge or IGeometryBridge2 - Interfaces and methods

コード

IPointCollection::AddPoints メソッドの場合

Help の指示に従い、IGeometryBridge (最新のインターフェイスは IGeometryBridge2)を使用して AddPoints を呼ぶようにします。

  public void AddPoints()
    {
        IPoint point1 = new PointClass();
        point1.PutCoords(10, 10);
        IPoint point2 = new PointClass();
        point2.PutCoords(20, 20);
        IPoint[] pointArray = new IPoint[2];

        pointArray[0] = point1;
        pointArray[1] = point2;
        IPointCollection4 pointCollection = new PolylineClass();
        //add points to pointCollection

        IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
        geometryBridge.AddPoints(pointCollection, ref pointArray);
        System.Windows.Forms.MessageBox.Show(pointCollection.PointCount + " points added to PointCollection");
    }
 Public Sub AddPoints()

        Dim point1 As IPoint = New PointClass()
        point1.PutCoords(10, 10)
        Dim point2 As IPoint = New PointClass()
        point2.PutCoords(20, 20)
        Dim pointArray As IPoint() = New IPoint(1) {}

        pointArray(0) = point1
        pointArray(1) = point2
        Dim pointCollection As IPointCollection4 = New PolylineClass()
        'add points to pointCollection

        Dim geometryBridge As IGeometryBridge = New GeometryEnvironmentClass()
        geometryBridge.AddPoints(pointCollection, pointArray)
        System.Windows.Forms.MessageBox.Show(pointCollection.PointCount & " points added to PointCollection")

 End Sub

メタデータ

種類

製品