Beispiel #1
0
        protected override void DrawOverlay(Rhino.Display.DrawEventArgs e)
        {
            base.DrawOverlay(e);

            List <Guid> noDupGUIDs = new List <Guid>();


            for (int i = 0; i < Ids.Count; i++)
            {
                if (noDupGUIDs.Contains(Ids[i]))
                {
                }
                else
                {
                    noDupGUIDs.Add(Ids[i]);
                    RhinoObject foundObject = Rhino.RhinoDoc.ActiveDoc.Objects.Find(Ids[i]);
                    int         isSelected  = foundObject.IsSelected(false);

                    switch (foundObject.ObjectType)
                    {
                    case Rhino.DocObjects.ObjectType.Point:
                        if (isSelected > 0)
                        {
                            e.Display.DrawDot(((Rhino.Geometry.Point)foundObject.Geometry).Location, i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
                        }
                        else
                        {
                            e.Display.DrawDot(((Rhino.Geometry.Point)foundObject.Geometry).Location, i.ToString(), System.Drawing.Color.Black, System.Drawing.Color.White);
                        }
                        break;

                    case Rhino.DocObjects.ObjectType.Curve:
                        Rhino.Geometry.Curve myCurve = (Rhino.Geometry.Curve)foundObject.Geometry;
                        myCurve.Domain = new Rhino.Geometry.Interval(0, 1);
                        if (isSelected > 0)
                        {
                            e.Display.DrawDot(myCurve.PointAtNormalizedLength(0.5), i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
                        }
                        else
                        {
                            e.Display.DrawDot(myCurve.PointAtNormalizedLength(0.5), i.ToString(), System.Drawing.Color.Black, System.Drawing.Color.White);
                        }
                        break;

                    case Rhino.DocObjects.ObjectType.Extrusion:
                        Rhino.Geometry.Extrusion myExtru         = (Rhino.Geometry.Extrusion)foundObject.Geometry;
                        Rhino.Geometry.Point3d   myExtruLocation = myExtru.GetBoundingBox(true).Center;
                        //Rhino.Geometry.Point3d myExtruCentroid = Rhino.Geometry.AreaMassProperties.Compute(myExtru.ToBrep()).Centroid;
                        if (isSelected > 0)
                        {
                            e.Display.DrawDot(myExtruLocation, i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
                        }
                        else
                        {
                            e.Display.DrawDot(myExtruLocation, i.ToString(), System.Drawing.Color.Black, System.Drawing.Color.White);
                        }
                        break;

                    case Rhino.DocObjects.ObjectType.Brep:
                        Rhino.Geometry.Brep    myBrep         = (Rhino.Geometry.Brep)foundObject.Geometry;
                        Rhino.Geometry.Point3d myBrepLocation = myBrep.GetBoundingBox(true).Center;
                        if (isSelected > 0)
                        {
                            e.Display.DrawDot(myBrepLocation, i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
                        }
                        else
                        {
                            e.Display.DrawDot(myBrepLocation, i.ToString(), System.Drawing.Color.Black, System.Drawing.Color.White);
                        }
                        break;

                    case Rhino.DocObjects.ObjectType.Mesh:
                        var mesh = foundObject.Geometry as Rhino.Geometry.Mesh;
                        Rhino.Geometry.Point3d myMeshLocation = mesh.GetBoundingBox(true).Center;
                        if (isSelected > 0)
                        {
                            e.Display.DrawDot(myMeshLocation, i.ToString(), System.Drawing.Color.Red, System.Drawing.Color.White);
                        }
                        else
                        {
                            e.Display.DrawDot(myMeshLocation, i.ToString(), System.Drawing.Color.Black, System.Drawing.Color.White);
                        }
                        break;

                    case Rhino.DocObjects.ObjectType.TextDot:
                        var textDot = (TextDot)foundObject.Geometry;
                        break;

                    case Rhino.DocObjects.ObjectType.Annotation:
                        var textObj = (Rhino.Geometry.TextEntity)foundObject.Geometry;
                        break;
                    }
                }
            }

            Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
        }