private void OnSelectElement(SelectionChangeArgs args)
 {
     if (!args.IsHighlightMode())
     {
         SelectedShapeQuery query = new SelectedShapeQuery();
         renderView.QuerySelection(query);
         var shape = query.GetGeometry();
         if (shape != null)
         {
             GeomCurve curve = new GeomCurve();
             if (curve.Initialize(shape))
             {
                 TopoShapeProperty property = new TopoShapeProperty();
                 property.SetShape(shape);
                 Console.WriteLine("Edge Length {0}", property.EdgeLength());
             }
         }
     }
 }
        private void BtnUp_Click(object sender, EventArgs e)
        {
            //Get selected shape
            SelectedShapeQuery context = new SelectedShapeQuery();

            renderViewDraw.QuerySelection(context);
            var face = context.GetGeometry();
            var line = context.GetSubGeometry();

            if (face == null || line == null)
            {
                return;
            }
            if (face.GetShapeType() != EnumTopoShapeType.Topo_FACE || line.GetShapeType() != EnumTopoShapeType.Topo_EDGE)
            {
                return;
            }

            //记录输入参数
            Bending bending = new Bending()
            {
                Direction = EnumDir.Edge_UP,
                Angle     = Convert.ToDouble(txtAngle.Text),
                Radius    = Convert.ToDouble(txtRadius.Text),
                Length    = Convert.ToDouble(txtLength.Text)
            };
            GeomCurve curve = new GeomCurve();

            curve.Initialize(line);
            Vector3 dirL = curve.DN(curve.FirstParameter(), 1);

            if (dirL.Y >= 0)
            {
                bending.Orientation = Math.Round(dirL.AngleBetween(Vector3.UNIT_X), 3);
            }
            else
            {
                bending.Orientation = Math.Round(360 - dirL.AngleBetween(Vector3.UNIT_X), 3);
            }

            //if (dirL.X == 1)
            //{
            //    bending.Orientation = 0;
            //}
            //else if (dirL.Y == 1)
            //{
            //    bending.Orientation = EnumEdge.Edge_2;
            //}
            //else if (dirL.X == -1)
            //{
            //    bending.Orientation = EnumEdge.Edge_3;
            //}
            //else
            //{
            //    bending.Orientation = EnumEdge.Edge_4;
            //}

            TopoShape sweep = BendUp(face, line, bending).Sweep;

            bendings.Add(bending);

            #region 渲染
            ElementId    faceId   = new ElementId(bending.Index + shapeId);
            ElementId    edgeId   = new ElementId(bending.Index);
            SceneManager sceneMgr = renderViewDraw.SceneManager;
            SceneNode    rootNode = GlobalInstance.TopoShapeConvert.ToSceneNode(sweep, 0.1f);
            SceneNode    faceNode = GlobalInstance.TopoShapeConvert.ToSceneNode(face, 0.1f);
            SceneNode    edgeNode = GlobalInstance.TopoShapeConvert.ToSceneNode(line, 0.1f);
            faceNode.SetId(faceId);
            faceNode.SetVisible(false);
            edgeNode.SetId(edgeId);
            edgeNode.SetVisible(false);
            if (rootNode != null)
            {
                sceneMgr.AddNode(rootNode);
                sceneMgr.AddNode(faceNode);
                sceneMgr.AddNode(edgeNode);
            }
            renderViewDraw.FitAll();
            renderViewDraw.RequestDraw(EnumRenderHint.RH_LoadScene);

            #endregion
        }