示例#1
0
        //this is where the logic of the command is defined
        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 the objects whose tags you need to delete");
                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();
                //Debug.WriteLine(tagName, "Tag");
            }

            doc.Objects.UnselectAll();
            TagUtil.DeleteTag(ref objs, tagName, true);
            //marking the document as dirty - i.e. modified so that it prompts the user to save when closed without saving
            doc.Modified = true;
            return(Result.Success);
        }