Example #1
0
        public IList <PFEdge> PickEdgeSingle(IList <PFEdge> available = null)
        {
            var pickedEdges = new List <PFEdge>();
            var doc         = Rhino.RhinoDoc.ActiveDoc;
            var selection   = new HashSet <PFEdge>();

            if (available != null && available.Count > 0)
            {
                selection = new HashSet <PFEdge>(available.Where(x => x.Id > 0));
            }
            else
            {
                selection = new HashSet <PFEdge>(Edges.Where(x => x.Id > 0));
            }
            var intPositiveEdges = Edges.Where(x => selection.Contains(x)).ToList();
            var midPoints        = intPositiveEdges.Select(x => PFVertex.AverageVertexes(x.Vertices));
            var edgeConduit      = new DrawPFEdgeConduit(intPositiveEdges)
            {
                Enabled = true
            };

            doc.Views.Redraw();
            var gEdge = new GetPFEdge(intPositiveEdges);

            gEdge.AddSnapPoints(midPoints.ToArray());
            while (true)
            {
                gEdge.SetCommandPrompt("select Edge by mid-point. (<ESC> to exit");
                gEdge.AcceptNothing(true);
                gEdge.AcceptString(true);
                //gVert.SetCursor() // this we can change after switching to Rhino 6 - api

                gEdge.SetDefaultString($"({pickedEdges.Count}) edges selected press <Enter> to accept");
                gEdge.Get(true);


                doc.Views.Redraw();
                var result    = gEdge.CommandResult();
                var strResult = gEdge.StringResult();
                pickedEdges = new List <PFEdge>();
                if (gEdge.CommandResult() == Rhino.Commands.Result.Cancel)
                {
                    break;
                }
                bool breakFlag = false;
                foreach (var edge in intPositiveEdges)
                {
                    if (edge.Picked)
                    {
                        edge.Picked = false;
                        pickedEdges.Add(edge);
                        breakFlag = true;
                        doc.Views.Redraw();
                        break;
                    }
                }

                if (breakFlag)
                {
                    break;
                }
                //edgeConduit.UpdateLines();
                //doc.Views.Redraw();

                if (gEdge.GotDefault())
                {
                    break;
                }
            }
            edgeConduit.Enabled = false;
            doc.Views.Redraw();
            return(pickedEdges);
        }
Example #2
0
        public IList <PFEdge> PickEdge(IList <PFEdge> available = null)
        {
            var pickedEdges = new List <PFEdge>();
            var doc         = Rhino.RhinoDoc.ActiveDoc;
            var selection   = new HashSet <PFEdge>();

            if (available != null && available.Count > 0)
            {
                selection = new HashSet <PFEdge>(available.Where(x => x.Id > 0));
            }
            else
            {
                selection = new HashSet <PFEdge>(Edges.Where(x => x.Id > 0));
            }
            var intPositiveEdges = Edges.Where(x => selection.Contains(x) && x.Vertices.All(y => !y.External)).ToList();
            var midPoints        = intPositiveEdges.Select(x => PFVertex.AverageVertexes(x.Vertices));
            var edgeConduit      = new DrawPFEdgeConduit(intPositiveEdges)
            {
                Enabled = true
            };

            doc.Views.Redraw();
            var gEdge = new GetPFEdge(intPositiveEdges);

            //var permOption = new OptionToggle(false, "temp", "perm");
            gEdge.SetCommandPrompt("select Edges by mid-points. (<ESC> to exit");
            //gEdge.AddOptionToggle("Remember", ref permOption);
            gEdge.AcceptNothing(true);
            gEdge.AcceptString(true);
            gEdge.AddSnapPoints(midPoints.ToArray());
            while (true)
            {
                gEdge.SetCursor(CursorStyle.Hand); // this we can change after switching to Rhino 6 - api

                gEdge.SetDefaultString($"({pickedEdges.Count}) edges selected press <Enter> to accept");
                gEdge.Get(true);


                doc.Views.Redraw();
                var result    = gEdge.CommandResult();
                var strResult = gEdge.StringResult();
                pickedEdges = new List <PFEdge>();
                if (gEdge.CommandResult() == Rhino.Commands.Result.Cancel)
                {
                    break;
                }
                foreach (var edge in intPositiveEdges)
                {
                    if (edge.Picked)
                    {
                        edge.Picked = false;
                        pickedEdges.Add(edge);
                        edge.TargetLength  = GetData.GetDoubleInViewport(PFVertex.AverageVertexes(edge.Vertices), edge.TargetLength);
                        edge.InfluenceCoef = 1;
                        doc.Views.Redraw();
                        break;
                    }
                }
                //edgeConduit.UpdateLines();
                //doc.Views.Redraw();

                if (gEdge.GotDefault())
                {
                    break;
                }
            }
            edgeConduit.Enabled = false;
            doc.Views.Redraw();
            return(pickedEdges);
        }