I am very new to ArcObjects. Can anyone help me to find the namespace for "copy parallel", which is under the Editor in ArcGIS desktop 10? I will be highly appreciated if you can provide an example about how to use it in Visual Studio 2010.
Asked
Active
Viewed 2,986 times
1 Answers
3
if you are actually just trying to execute the "Copy Parallel..." command... you can do so like this
IDocument d = ArcMap.Document as IDocument;
IUID ud = new UIDClass();
ud.Value = "esriEditor.CopyParallelCommand";
ICommandItem c = d.CommandBars.Find(ud);
c.Execute();
If you're trying to programmatically duplicate the copy parallel, the only I've found is using the IConstructCurve3 to mimick the operation. This method seems to almost have the same parameters.
//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();
I've only hacked up the pertinent part with IConstructCurve3, make sure you do your checks and if desire, copy the source feature attribute over.
If you have VS2010, this code will run if you simply create an Button Addin by using the ESRI ArcMap Addin Project Template with a button. Then copy and paste the code into the OnClick() event. (of course, don't forget to set up the necessary esri references)

JTran
- 56
- 1
-
I have to say "Thanks" first before I go into it. I may have more questions later. Thanks a lot. – user1293655 Mar 27 '12 at 14:14
-
Your code worked great. I really appreciate your help. I have been reading ArcObjects SDK 10 Microsoft .NET Framework for three weeks. still not sure how to start writing a code. Could you point me to the right direction where to start? Such as where I can find the command like "esriEditor.CopyParallelCommand", in any book or in any instruction? I have been using ArcGIS desktop a lot and can write python code. But i am quite new to ArcObjects using c#. Thanks again. Waiting for your reply. – user1293655 Mar 27 '12 at 14:59
-
If you are completely new to ArcObjects... I still believe ESRI has some pretty good development documentation. This site. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html is probably the best place to start. Find anything in the table of content with the word "Walkthrough:" and it pretty much expains things step by step. So just open VS2010 and go at it with any of the walkthrough and you'll get the idea. Good luck. – JTran Mar 28 '12 at 05:54
-
A list of command references is found here: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000029s000000 In most cases, you may just call these stock commands to get your job done, but most (or even all) of these commands actually have lower-level ArcObjects counterparts that you can further control. But you will need to dig them up. – JTran Mar 28 '12 at 06:07
-
Thanks, JTran. You are my biggest help. Now i think all i can do is to look through the stuff again, even though it make my head big and dizzy. And thanks again for pointing me to the right direction. – user1293655 Mar 28 '12 at 13:38