1

我对 ArcObjects 很陌生。谁能帮我找到“复制并行”的命名空间,它位于 ArcGIS Desktop 10 的编辑器下?如果您能提供有关如何在 Visual Studio 2010 中使用它的示例,我将不胜感激。

4

1 回答 1

3

如果您实际上只是尝试执行“复制并行...”命令...您可以这样做

        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 回答