Cut polygons without selection edit task for arcmap v10 sp3

4763
18
Jump to solution
02-16-2012 11:16 PM
by Anonymous User
Not applicable
Original User: bwragg

Hi all,

I've spent days now trying to get the "Cut polygons without selection" sample (
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Cut_polygons_wit...) to work with ArcMap v10 sp3 (ArcView). We need this extension so we can trace selected features without selecting the polygon we want to split. I know what your going to say..."just use the normal 'Cut polygon tools' with the new trace tool that doesn't require to select features' but we can't use this tool as we have really complex data and we have to trace long distances. As a result when we have tested the new 'trace without a selection' feature we end up accidentally tracing many small features. Hence we would like to get this old sample working.

I'm not a vb developer but with some help from a developer I've downloaded the vb.net solution and compiled it. I've run ESRIRegAsm, select Desktop and it succeeds in registering it. I've checked the dependancies with dependancy walker and its all good. I've checked the Components.exe program and I can see it registers itself under "ESRI Engine Edit Tasks" but not under "ESRI Edit Tasks" which is the spot you would put it in 9.3 and 9.2. When I run ArcMap I can't see the task 'Cut Polygon without selection' in the task list. I assume this is because its not added in the Components.exe under "ESRI Edit Tasks". If I manually try to add it throws an error saying 'Can't Load Library'.

So is there a way to get this sample to compile and install so that it runs as a task in the normal Editor toolbar in ArcMap? Or have I missed some readme that explains this sample is only available in the Engine?

Also is there a reason ESRI doens't compile this as a dll like they used to for previous versions?

Thanks,

bwragg
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Ok, the ported sample is up on arcgis.com as the Cut Polygons Without Selection Tool code sample.
This is a visual studio 2010 project that will create a 10.1 desktop add-in for use in ArcMap.

The code is included so you can generally see the pattern for creating edit tools that use the sketch in the 10.x framework.
The tool was created using the esri add-in templates in visual studio by creating a construction tool but without the category part, thus you still get an edit tool template that uses the sketch but without it being a construction tool. The code from the OnFinishSketch method in the engine edit task was then ported to the OnSketchFinished method in the add-in.

You can create COM dll for use in 10.0.x using the same pattern but by using the Desktop ArcMap Edit Tool template in the ArcGIS New Item wizard when creating a new class in your com dll project. Stick the code in the m_editEvents_OnSketchFinished method. Note that this has to be a com dll at 10.0.x because add-ins do not support implementing interfaces until 10.1, and you need to implement ISketchTool to use the sketch. Consider changing the ArrayList to generics and use a different method for the sketch-polygon intersection if you take this on.

View solution in original post

0 Kudos
18 Replies
by Anonymous User
Not applicable
Original User: agray1

The reason you can't use this sample in ArcMap is that it is made for engine.

Implements ESRI.ArcGIS.Controls.IEngineEditTask

 Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
    Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
    EngineEditTasks.Register(regKey)

  End Sub
  ''' <summary>
  ''' Required method for ArcGIS Component Category unregistration -
  ''' Do not modify the contents of this method with the code editor.
  ''' </summary>
  Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
    Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
    EngineEditTasks.Unregister(regKey)

...

#Region "Private Members"
  Private m_engineEditor As IEngineEditor
  Private m_editSketch As IEngineEditSketch
  Private m_editLayer As IEngineEditLayers
#End Region


  End Sub


You could try to use the ArcGIS developer templates (installed with the arcgis developer kit) to create an ArcMap edit task and copy the code (not all the code, just the methods that make up the interface) and the member variables.  You would have to convert all the classes specific to engine to the a similar class specific to ArcMap.  Probably a task that an ArcObjects developer could undertake.
0 Kudos
by Anonymous User
Not applicable
Original User: bwragg

The reason you can't use this sample in ArcMap is that it is made for engine.

Implements ESRI.ArcGIS.Controls.IEngineEditTask

 Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
    Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
    EngineEditTasks.Register(regKey)

  End Sub
  ''' <summary>
  ''' Required method for ArcGIS Component Category unregistration -
  ''' Do not modify the contents of this method with the code editor.
  ''' </summary>
  Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
    Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
    EngineEditTasks.Unregister(regKey)

...

#Region "Private Members"
  Private m_engineEditor As IEngineEditor
  Private m_editSketch As IEngineEditSketch
  Private m_editLayer As IEngineEditLayers
#End Region


  End Sub


You could try to use the ArcGIS developer templates (installed with the arcgis developer kit) to create an ArcMap edit task and copy the code (not all the code, just the methods that make up the interface) and the member variables.  You would have to convert all the classes specific to engine to the a similar class specific to ArcMap.  Probably a task that an ArcObjects developer could undertake.


Thanks agray, I had an feeling that might be the answer I got. Guess we'll have to start trying to convert the code. Thanks again for your time.

I'm sure I'm not the first person who's had to do this...anyone out there got a compiled dll already???

Thanks
0 Kudos
ThaiTruong
Occasional Contributor II
Hi Ben,

I know that this thread has been for awhile, were you be able to re-create this tool?
0 Kudos
by Anonymous User
Not applicable
Original User: bwragg

Hi Ben,

I know that this thread has been for awhile, were you be able to re-create this tool?


Hi, Sorry for the late reply, no I haven't been able to re-create this tool but would love to hear any information you may have on this.

Thanks,

bwragg
0 Kudos
JohnSobetzer
Frequent Contributor
I found this to be an essential tool in 9x since it: 1. allowed cutting without having to select a polygon (saving the time and clicks involved in changing to the select tool, making a selection and then changing back to the sketch tool), and 2. it allowed cutting using selected features and the trace tool.

I would still like this tool in 10x.  I went through a lot of the same wasted effort with the developer sample before finding out it was only for Engine.  It could avoid the selection clicks when using a sketch to cut a polygon.  As for using the trace tool, in 10x the cut polygon tool combined with the trace tool is really nice, but tracing can be difficult in places where there are many features at the scale one is editing.  So in 10x I'd like both the built in and the cut without selecting versions, and in both have the ability to use 10's trace without selecting, or to use 9's trace using only the selected features for more control.
0 Kudos
by Anonymous User
Not applicable
Original User: sean_jones

I'll take a crack at the conversion and post it up on editing labs.

In the meantime you can:
Union the selected set of lines you would have traced, into an empty temporary layer.
Using the cut polygon tool, replace the sketch with the line you just unioned.
0 Kudos
by Anonymous User
Not applicable
Ok, the ported sample is up on arcgis.com as the Cut Polygons Without Selection Tool code sample.
This is a visual studio 2010 project that will create a 10.1 desktop add-in for use in ArcMap.

The code is included so you can generally see the pattern for creating edit tools that use the sketch in the 10.x framework.
The tool was created using the esri add-in templates in visual studio by creating a construction tool but without the category part, thus you still get an edit tool template that uses the sketch but without it being a construction tool. The code from the OnFinishSketch method in the engine edit task was then ported to the OnSketchFinished method in the add-in.

You can create COM dll for use in 10.0.x using the same pattern but by using the Desktop ArcMap Edit Tool template in the ArcGIS New Item wizard when creating a new class in your com dll project. Stick the code in the m_editEvents_OnSketchFinished method. Note that this has to be a com dll at 10.0.x because add-ins do not support implementing interfaces until 10.1, and you need to implement ISketchTool to use the sketch. Consider changing the ArrayList to generics and use a different method for the sketch-polygon intersection if you take this on.
0 Kudos
by Anonymous User
Not applicable
Original User: johns

Excellent!  It works either with the feature templates or with my customized classic editing in 10.1.  Thank you very much Sean.
0 Kudos
ThaiTruong
Occasional Contributor II
Attached is a COM component version of this tool allows us to create sketch of cut line by using other sketch tools like: Right Angle, Arc, End Point Arc, Tangent Curve, & Bezier Curve.

[ATTACH=CONFIG]15790[/ATTACH]

To use:
1. Install this tool
2. Start Editing from Editor toolbar.
3. Select a polygon feature class that you want to edit.
4. Select Cut Polygons Without Selection tool from Construction Tools.
5. Sketch on map to create a line that cuts through the original polygon(s) as desired.
6. You can create your sketch with any Feature Construction (straight lines, with curves, or tracing from the shapes of other features) to place vertices in the sketch. Youâ??ll be able to use snap, too.
7. Double click, press F2 key, or Right-click anywhere on the map and choose Finish Sketch to complete you cut line.
0 Kudos