Exemplo n.º 1
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            List <RhinoObject> objs = new List <RhinoObject>();

            using (GetObject getter = new GetObject())
            {
                getter.EnablePreSelect(true, false);
                getter.SetCommandPrompt("Select all the objects you want to tag");
                getter.AcceptColor(false);
                getter.AcceptString(false);
                getter.GroupSelect = true;
                getter.GetMultiple(1, 0);
                if (getter.CommandResult() != Result.Success)
                {
                    return(getter.CommandResult());
                }

                for (int i = 0; i < getter.ObjectCount; i++)
                {
                    objs.Add(getter.Object(i).Object());
                }
            }

            string tagName;

            using (GetString getter = new GetString())
            {
                getter.SetCommandPrompt("Enter the tag");
                if (getter.Get() != GetResult.String)
                {
                    RhinoApp.WriteLine("Invalid Input for tag");
                    return(getter.CommandResult());
                }
                tagName = getter.StringResult();
            }

            TagUtil.AddTag(objs, tagName, true);
            doc.Modified = true;
            doc.Objects.UnselectAll();
            doc.Views.Redraw();
            return(Result.Success);
        }