Edit Bezier curve

537
4
09-06-2011 09:56 PM
VictorAparicio
New Contributor
I need to edit a Bézier curve Element with a text along it and I wonder if there is any sketch class or command like the ArcMap´s Edit vertices command. I have tried with a BezierMovePointFeedbackClass but the Start method needs a vertex index like parameter and I can get only the first vertex of the curve with a HitTest object.

Any ideas???

Thanks in advance!
0 Kudos
4 Replies
by Anonymous User
Not applicable
You can edit the baseline manually in desktop via the edit annotation tool sketch context menu command 'edit baseline sketch' and via code by getting the annotation element and manipulating its geometry.

Here's some code to get the baseline geometry of a selected anno element

  // The Selection tracker will �??prep�?? the element�??s geometry for editing (basically smooth it out),
  // otherwise you can get the geometry right off the element.
  IAnnotationFeature anno = feature as IAnnotationFeature;
  IElement element = anno.Annotation;
  element.Activate(GetDisplay());
  IElementEditVertices editVertices = element as IElementEditVertices;
  ISelectionTracker selectionTracker = editVertices.GetMoveVerticesSelectionTracker();
  IGeometry geom = selectionTracker.Geometry;

  // Modify geometry as you like then reassign back to the element

  element.Geometry = geom;

  // Update the feature...
  editor.StartOperation();
  anno.Annotation = element;
  feature.Store();
  editor.StopOperation(�??Some String�?�);

We dont get many questions on this so can you give us some more information on what types of edits you want to do here.
Thanks
0 Kudos
VictorAparicio
New Contributor
Thanks for your answer Sean. I´m developing an application in ArcGIS Engine 9.3.1 and I have to allow the user to draw figures over maps and then modify them. The figures can be any annotation the user want to show in a map (points, polylines, polygons, text and polylines with text along it), for example a forest fire, an accident, etc.

I cannot use the Editor, because it is a desktop object, but thanks to your post I realized I can use IElementVertices and ISelectionTracker. Unfortunately it doesn´t work (I don´t know why because with polylines works perfectly) with Bezier curves as my text with polyline is...

My code is like this:

        public override void OnClick()
        {
            try
            {
                m_HitElement = ((IGraphicsContainerSelect)AxMapControl1.Map).SelectedElement(0);
                if (m_HitElement is IGroupElement)
                {
                    m_EditVertices = (IElementEditVertices) IGroupElement)m_HitElement).get_Element(0);
                }
                else
                {
                    m_EditVertices = (IElementEditVertices)m_HitElement;
                }
                m_HitElement.Activate((IDisplay)AxMapControl1.ActiveView.ScreenDisplay);
                m_EditVertices.MovingVertices = true;
                m_SelectionTracker = m_EditVertices.GetMoveVerticesSelectionTracker();
                m_SelectionTracker.Display = AxMapControl1.ActiveView.ScreenDisplay;
                m_SelectionTracker.ShowHandles = true;
                AxMapControl1.ActiveView.Refresh();
            }
            catch (Exception Err)
            {
               
            }
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            try
            {
                m_SelectionTracker.OnMouseUp(Button, Shift, X, Y);
                m_HitElement.Geometry = m_SelectionTracker.Geometry;

                AxMapControl1.ActiveView.GraphicsContainer.UpdateElement(m_HitElement);
                AxMapControl1.ActiveView.Refresh();
            }
            catch (Exception Err)
            {
               
            }
        }

Thanks again

Víctor Aparicio
0 Kudos
LukeBadgerow
New Contributor

We dont get many questions on this so can you give us some more information on what types of edits you want to do here.
Thanks[/QUOTE wrote:


I don't want to hijack your thread, but when I update the geometry of my annotation, I'm losing my actual annotation (the text component).  The method below is what I'm implementing here:

        private void ExperimentalMethod(int objectid, IFeatureLayer newlayer, IFeatureLayer existinglayer) {
            IFeature newfeature = newlayer.FeatureClass.GetFeature(objectid);
            IFeature existingfeature = FindNearestAnnotation(newfeature, existinglayer);
            IGeometry existinggeometry = existingfeature.Shape;
            IAnnotationFeature annofeat = (IAnnotationFeature)newfeature;
            
            IElement element = annofeat.Annotation;
            element.Activate(ArcMap.Document.ActiveView.ScreenDisplay);
            element.Geometry = existinggeometry;
            
            ITextElement textelement = (ITextElement)element;
            ITextSymbol symbol = textelement.Symbol;
            
            symbol.Angle = (double)existingfeature.get_Value(
                existingfeature.Fields.FindField("Angle"));

            symbol.Text = newfeature.get_Value(
                newfeature.Fields.FindField("TextString")).ToString();

            textelement.Symbol = symbol;
            annofeat.Annotation = (IElement)textelement;
            newfeature = (IFeature)annofeat;
            newfeature.Store();

        }
0 Kudos
VictorAparicio
New Contributor
Well, finally I could not edit the Bézier curve with the IElementEditVertices and the ISelectionTracker classes, so I have to develope my custom edit class.
I have drawn every control vertex and every tangent line of the curve and then capture the mouse down position with a IHitTest class. Then, with the point and the index of the vertex, I have used a BezierMovePointFeedbackClass to help the user edit the curve.
0 Kudos