2012-03-26 6 views

답변

3

"Copy Parallel ..."명령을 실제로 실행하려고하면 다음과 같이 할 수 있습니다. 프로그래밍 복사 평행을 복제하려는 경우이

 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 Project 템플릿을 사용하여 단추 추가 기능을 만들면이 코드가 실행됩니다. 그런 다음 코드를 복사하여 OnClick() 이벤트에 붙여 넣습니다. (물론, 필요한 esri 참조를 설정하는 것을 잊지 마세요)

+0

내가 들어가기 전에 먼저 "고맙다"고 말해야합니다. 나중에 더 많은 질문이있을 수 있습니다. 고마워. – user1293655

+0

코드가 잘 작동했습니다. 도와 주셔서 정말 고맙습니다. ArcObjects SDK 10 Microsoft .NET Framework를 3 주 동안 읽었습니다. 여전히 코드를 작성하는 방법을 잘 모릅니다. 시작할 방향을 가르쳐 주시겠습니까? 내가 "esriEditor.CopyParallelCommand"와 같은 명령을 어디서나 또는 어떤 명령에서 찾을 수 있는지? 저는 ArcGIS 데스크탑을 많이 사용하여 파이썬 코드를 작성할 수 있습니다. 하지만 저는 C#을 사용하여 ArcObjects를 처음 접했습니다. 다시 한번 감사드립니다. 당신의 응답을 기다리는. – user1293655

+0

ArcObjects를 처음 접한다면 아직 ESRI가 꽤 좋은 개발 문서를 가지고 있다고 생각합니다. 이 장소. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html이 아마도 가장 좋은 장소 일 것입니다. "Walkthrough :"라는 단어로 내용 표에서 무엇이든 찾으십시오. VS2010을 열고 연습 중 하나를 선택하면 아이디어를 얻을 수 있습니다. 행운을 빕니다. – JTran