Every Rhino.NET Plug-In must have one and only one MRhinoPlugIn derived class. DO NOT create an instance of this class. It is the responsibility of Rhino.NET to create an instance of this class and register it with Rhino.
Наследование: RMA.Rhino.MRhinoUtilityPlugIn
        private void EstimatorTagForm_Load(object sender, EventArgs e)
        {
            if (this.m_type == EstimatorTag.tag_type.item_tag)
            {
                this.m_list.MultiSelect = false;
            }

            this.Text     = m_str_title;
            m_prompt.Text = m_str_prompt;

            EstimatorPlugIn plugin = RMA.Rhino.RhUtil.GetPlugInInstance() as EstimatorPlugIn;

            for (int i = 0; i < plugin.m_tag_table.TagCount(); i++)
            {
                EstimatorTag tag = plugin.m_tag_table[i];
                if (tag.Type() == m_type)
                {
                    ListViewItem item = new ListViewItem(tag.Id());
                    item.SubItems.Add(tag.Description());
                    item.Tag = i;
                    m_list.Items.Add(item);
                }
            }

            m_list.Columns.Add("Tag");
            m_list.Columns.Add("Description");

            foreach (ColumnHeader ch in m_list.Columns)
            {
                ch.Width = -2;
            }
        }
Пример #2
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            EstimatorPlugIn          plugin = RMA.Rhino.RhUtil.GetPlugInInstance() as EstimatorPlugIn;
            Dictionary <string, int> map    = new Dictionary <string, int>();

            MRhinoObjectIterator it = new MRhinoObjectIterator(
                IRhinoObjectIterator.object_state.undeleted_objects,
                IRhinoObjectIterator.object_category.active_and_reference_objects);

            foreach (MRhinoObject obj in it)
            {
                string[] string_array = null;
                if (0 == EstimatorHelpers.GetData(obj, ref string_array))
                {
                    continue;
                }

                for (int i = 0; i < string_array.Length; i++)
                {
                    string tag   = string_array[i];
                    int    index = plugin.m_tag_table.FindTag(tag);
                    if (index >= 0)
                    {
                        if (plugin.m_tag_table.Tag(index).Type() == EstimatorTag.tag_type.item_tag)
                        {
                            if (!map.ContainsKey(tag))
                            {
                                map.Add(tag, 1);
                            }
                            else
                            {
                                map[tag]++;
                            }
                        }
                    }
                }
            }

            if (map.Count > 0)
            {
                foreach (KeyValuePair <string, int> kvp in map)
                {
                    RhUtil.RhinoApp().Print(String.Format("Item = {0}, Count = {1}\n", kvp.Key, kvp.Value));
                }
            }
            else
            {
                RhUtil.RhinoApp().Print("No Estimator item tag data found.\n");
            }


            return(IRhinoCommand.result.success);
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            RhinoGetVolumeObjects go = new RhinoGetVolumeObjects();

            go.SetCommandPrompt("Select objects to apply area tags");
            go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.polysrf_object | IRhinoGetObject.GEOMETRY_TYPE_FILTER.mesh_object);
            go.EnableSubObjectSelect(false);
            go.GetObjects(1, 0);
            if (go.CommandResult() != IRhinoCommand.result.success)
            {
                return(go.CommandResult());
            }

            EstimatorTagForm form = new EstimatorTagForm();

            form.m_str_title  = "Add Volume Tags";
            form.m_str_prompt = "Select one or more volume tags.";
            form.m_type       = EstimatorTag.tag_type.volume_tag;

            DialogResult rc = form.ShowDialog();

            if (rc == DialogResult.Cancel)
            {
                return(IRhinoCommand.result.cancel);
            }

            List <string> tag_strings = new List <string>(form.m_selected_tags.Count);

            EstimatorPlugIn plugin = RMA.Rhino.RhUtil.GetPlugInInstance() as EstimatorPlugIn;
            int             i      = 0;

            for (i = 0; i < form.m_selected_tags.Count; i++)
            {
                int index = form.m_selected_tags[i];
                tag_strings.Add(plugin.m_tag_table[index].Id());
            }

            for (i = 0; i < go.ObjectCount(); i++)
            {
                EstimatorHelpers.AddData(go.Object(i).Object(), tag_strings.ToArray());
            }

            return(IRhinoCommand.result.success);
        }
Пример #4
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();

            go.SetCommandPrompt("Select objects to apply item tag");
            go.EnableSubObjectSelect(false);
            go.GetObjects(1, 0);
            if (go.CommandResult() != IRhinoCommand.result.success)
            {
                return(go.CommandResult());
            }

            EstimatorTagForm form = new EstimatorTagForm();

            form.m_str_title  = "Add Item Tag";
            form.m_str_prompt = "Select an item tag.";
            form.m_type       = EstimatorTag.tag_type.item_tag;

            DialogResult rc = form.ShowDialog();

            if (rc == DialogResult.Cancel)
            {
                return(IRhinoCommand.result.cancel);
            }

            List <string> tag_strings = new List <string>(form.m_selected_tags.Count);

            EstimatorPlugIn plugin = RMA.Rhino.RhUtil.GetPlugInInstance() as EstimatorPlugIn;
            int             i      = 0;

            for (i = 0; i < form.m_selected_tags.Count; i++)
            {
                int index = form.m_selected_tags[i];
                tag_strings.Add(plugin.m_tag_table[index].Id());
            }

            for (i = 0; i < go.ObjectCount(); i++)
            {
                EstimatorHelpers.RemoveAllData(go.Object(i).Object());
                EstimatorHelpers.AddData(go.Object(i).Object(), tag_strings.ToArray());
            }

            return(IRhinoCommand.result.success);
        }