AnsweredAssumed Answered

Ask for Sketch from user

Question asked by mjk5000 on Apr 19, 2018
Latest reply on Apr 20, 2018 by mjk5000

After drawing a polygon on my map.  i am required to get a direction Polyline from the user.  In ArcObjects, I was able to accomplish this like the following.  This would give me a line that a user drew that represented a "direction"

 

                IActiveView activeView = pDocument.ActiveView;
                IScreenDisplay screenDisplay = activeView.ScreenDisplay;

                string cursorLocation = ProMapSettings.AssemblyDirectory + @ProMapSettings.CursorFileLocation + "RowDirection.cur";
                bool cursorLocationExists = File.Exists(cursorLocation);
                if (cursorLocationExists)
                {
                    System.Windows.Forms.Cursor newCursor = new System.Windows.Forms.Cursor(cursorLocation);
                    System.Windows.Forms.Cursor.Current = newCursor;
                }

                screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);

                IGeometry lineGeom = new PolylineClass();
                IRubberBand rubberBand = new RubberLineClass();
                if (rubberBand.TrackExisting(screenDisplay, null, lineGeom))
                {
                    lineGeom = rubberBand.TrackNew(screenDisplay, null) as IPolyline;
                }
                screenDisplay.FinishDrawing();

                polyline = (IPolyline)lineGeom;

 

In ArcGIS Pro, i understand how to create overlays and use map tools to create features, but can't quite figure out how to get a drawing from a user from within the code.  If there was a way I could trigger a MapTool that would be great too, but can't quite figure out how to get that to work and wait for it in code.  I want something like this.

 

//I need something like this to work, and then get result back to use the geometry                            
AddOverlayTool adt = new AddOverlayTool(RowLine);
Polyline mPolyline = await adt.startSketch();

//Then I use that line to get the angle and do more work                           
if (!mPolyline.IsNullOrEmpty())


Outcomes