Edit Sketch Properties - ArcScene + C#

919
2
Jump to solution
05-10-2012 11:31 PM
RustamTimerbaev
New Contributor II
How to edit sketch properties (Lines or Points)? I need change Z-value in selected objects with C#, but don't know how.
0 Kudos
1 Solution

Accepted Solutions
RustamTimerbaev
New Contributor II
        private void button2_Click(object sender, EventArgs e)         {             IEditor m_editor;             m_application = ArcSceneAddin1.ArcScene.Application;             edUID.Value = "esriEditor.Editor";             m_editor = m_application.FindExtensionByCLSID(edUID) as IEditor;             IEditSketch3 edSketch = m_editor as IEditSketch3;              int selectedvertexcount;             selectedvertexcount = edSketch.SelectedVertexCount;               IPointCollection4 ptColl = edSketch.Geometry as IPointCollection4;              ISketchOperation2 sketchOp = new SketchOperationClass();             sketchOp.Start(m_editor);             IPoint pt = ptColl.get_Point(0);               if (radioButton1.Checked)             {                 for (int i = 0; i < ptColl.PointCount; i++)                 {                     pt = ptColl.get_Point(i);                     IPoint pt_c = pt;                     pt_c.Z = height;                     ptColl.UpdatePoint(i, pt_c);                 }; //constant             };              if (radioButton2.Checked)             {                 for (int i = 0; i < ptColl.PointCount; i++)                 {                     pt = ptColl.get_Point(i);                     IPoint pt_c = pt;                     pt_c.Z += height;                     ptColl.UpdatePoint(i, pt_c);                 }; //add to current height             };               sketchOp.MenuString = "height change to selected object.";             edSketch.Geometry = ptColl as IGeometry;             sketchOp.Finish(edSketch.Geometry.Envelope,                 esriSketchOperationType.esriSketchOperationVertexDeleted, pt);           }


Thx for help, ESRI community...

View solution in original post

0 Kudos
2 Replies
RustamTimerbaev
New Contributor II
        private void button2_Click(object sender, EventArgs e)
        {
            IEditor m_editor;
            m_application = ArcSceneAddin1.ArcScene.Application;

            UIDClass edUID = new UIDClass();
            edUID.Value = "esriEditor.Editor";
            m_editor = m_application.FindExtensionByCLSID(edUID) as IEditor;
            IEditSketch3 edSketch = m_editor as IEditSketch3;
            int selectedvertexcount;
            selectedvertexcount = edSketch.SelectedVertexCount;
            MessageBox.Show("SelectedVertexCount = " + selectedvertexcount.ToString() + "\nLastPoint.Z = " + edSketch.LastPoint.Z);
            edSketch.LastPoint.Z = 145;
        }


Here LastPoint.Z = 146.
But
edSketch.LastPoint.Z = 145;
not change this value...
And yes, after pressing to 'Button2' i see error "Unable to save document" when i close ArcScene with saving.
0 Kudos
RustamTimerbaev
New Contributor II
        private void button2_Click(object sender, EventArgs e)         {             IEditor m_editor;             m_application = ArcSceneAddin1.ArcScene.Application;             edUID.Value = "esriEditor.Editor";             m_editor = m_application.FindExtensionByCLSID(edUID) as IEditor;             IEditSketch3 edSketch = m_editor as IEditSketch3;              int selectedvertexcount;             selectedvertexcount = edSketch.SelectedVertexCount;               IPointCollection4 ptColl = edSketch.Geometry as IPointCollection4;              ISketchOperation2 sketchOp = new SketchOperationClass();             sketchOp.Start(m_editor);             IPoint pt = ptColl.get_Point(0);               if (radioButton1.Checked)             {                 for (int i = 0; i < ptColl.PointCount; i++)                 {                     pt = ptColl.get_Point(i);                     IPoint pt_c = pt;                     pt_c.Z = height;                     ptColl.UpdatePoint(i, pt_c);                 }; //constant             };              if (radioButton2.Checked)             {                 for (int i = 0; i < ptColl.PointCount; i++)                 {                     pt = ptColl.get_Point(i);                     IPoint pt_c = pt;                     pt_c.Z += height;                     ptColl.UpdatePoint(i, pt_c);                 }; //add to current height             };               sketchOp.MenuString = "height change to selected object.";             edSketch.Geometry = ptColl as IGeometry;             sketchOp.Finish(edSketch.Geometry.Envelope,                 esriSketchOperationType.esriSketchOperationVertexDeleted, pt);           }


Thx for help, ESRI community...
0 Kudos