如何使用ArcObjects“复制并行”,哪个ESRI名称空间“复制并行”属于?

时间:2012-03-26 17:59:10

标签: desktop arcobjects arcmap

我是ArcObjects的新手。任何人都可以帮我找到“复制并行”的命名空间,这是在ArcGIS桌面10的编辑器下吗?如果您能提供有关如何在Visual Studio 2010中使用它的示例,我将非常感谢。

1 个答案:

答案 0 :(得分: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 Addin项目模板创建一个Button Addin,则会运行此代码。然后将代码复制并粘贴到OnClick()事件中。 (当然,不要忘记设置必要的esri参考)