1

私は ArcObjects を初めて使用します。ArcGIS Desktop 10 のエディターの下にある「コピー パラレル」の名前空間を見つけるのを手伝ってくれる人はいますか? Visual Studio 2010 での使用方法の例を提供していただければ幸いです。

4

1 に答える 1

3

実際に「CopyParallel...」コマンドを実行しようとしている場合は、次のように実行できます。

        IDocument d = ArcMap.Document as IDocument;
        IUID ud = new UIDClass();
        ud.Value = "esriEditor.CopyParallelCommand"; 
        ICommandItem c = d.CommandBars.Find(ud);
        c.Execute(); 

プログラムでコピーを並列に複製しようとしている場合、私が見つけたのは、IConstructCurve3を使用して操作を模倣することだけです。この方法はほとんど同じパラメータを持っているようです。

        //Get the selection
        UID uid = new UIDClass();
        uid.Value = "esriEditor.Editor";

        IEditor editor;
        editor = (IEditor)ArcMap.Application.FindExtensionByCLSID(uid);

        //Get Selection
        IEnumFeature enumfeature = editor.EditSelection;
        IFeature f = enumfeature.Next();

        //For adding new features
        IFeatureClass fc = f.Class as IFeatureClass;

        //Start an operation for undo/redo
        editor.StartOperation();
        while (f != null)
        {

            //Interface to do a "copy parallel"
            IConstructCurve3 construct = new PolylineClass();

            //Rounded, Mitered, etc
            object offset = esriConstructOffsetEnum.esriConstructOffsetRounded;

            IPolyline source = f.Shape as IPolyline; 

            //Method call (0.001 or -0.001 determines left/right)
            construct.ConstructOffset(source, 0.001, ref offset);

            //Storing output shape
            IFeature newFeature = fc.CreateFeature();
            newFeature.Shape = (IGeometry)construct;

            newFeature.Store();


            f = enumfeature.Next(); 
        }

        editor.StopOperation("Copy Parallel");

        //refresh
        ArcMap.Document.ActiveView.Refresh();

私はIConstructCurve3で関連部分をハックしただけです。必ずチェックを行い、必要に応じてソース機能属性をコピーしてください。

VS2010を使用している場合、ボタン付きのESRI ArcMapアドインプロジェクトテンプレートを使用してボタンアドインを作成するだけで、このコードが実行されます。次に、コードをコピーしてOnClick()イベントに貼り付けます。(もちろん、必要なesri参照を設定することを忘れないでください)

于 2012-03-27T03:58:32.613 に答える