Example #1
0
        /// <summary>
        /// Add an array of 3-D points to the document
        /// </summary>
        public object AddPoints(object pointsObj)
        {
            On3dPointArray points = new On3dPointArray();

            if (SampleCsRhinoScriptUtils.ConvertToOn3dPointArray(pointsObj, ref points))
            {
                MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();
                if (null != doc)
                {
                    ArrayList objectIds = new ArrayList();
                    for (int i = 0; i < points.Count(); i++)
                    {
                        MRhinoObject rhinoObj = doc.AddPointObject(points[i]);
                        if (null != rhinoObj)
                        {
                            objectIds.Add(rhinoObj.ModelObjectId().ToString());
                        }
                    }
                    if (objectIds.Count > 0)
                    {
                        doc.Redraw();
                        return(objectIds.ToArray());
                    }
                }
            }
            return(null);
        }
        private void m_listbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_bInEvent)
            {
                return;
            }

            m_bInSelect = true;
            MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();

            // Select what got selected
            ListBox.SelectedIndexCollection selected = m_listbox.SelectedIndices;

            // Select what got selected
            int i = 0;

            for (i = 0; i < selected.Count; i++)
            {
                int index = selected[i];
                if (!m_selected.Contains(index))
                {
                    Guid         guid = new Guid(m_listbox.Items[index].ToString());
                    MRhinoObject obj  = doc.LookupObject(guid);
                    if (obj != null && obj.IsSelectable())
                    {
                        obj.Select(true);
                    }
                }
            }

            // Unselect what got unselected
            for (i = 0; i < m_selected.Count; i++)
            {
                int index = m_selected[i];
                if (!selected.Contains(index))
                {
                    Guid         guid = new Guid(m_listbox.Items[index].ToString());
                    MRhinoObject obj  = doc.LookupObject(guid);
                    if (obj != null)
                    {
                        obj.Select(false);
                    }
                }
            }

            SaveSelectedIndices();
            doc.Redraw();

            m_bInSelect = false;
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Since our form is modeless, the user can run commands
            // while our form is visible, including the Open command,
            // which closes the current document and opens a new one.
            // Thus, it's best to always ask for the active document
            // instead of maintaining a reference to the document passed
            // to the command that created this form.
            MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();

            if (null != doc)
            {
                On3dPoint a    = new On3dPoint(0.0, 0.0, 0.0);
                On3dPoint b    = new On3dPoint(5.0, 5.0, 5.0);
                OnLine    line = new OnLine(a, b);
                doc.AddCurveObject(line);
                doc.Redraw();
            }
        }
Example #4
0
        /// <summary>
        /// Add a 3-D point to the document
        /// </summary>
        public object AddPoint(object pointObj)
        {
            On3dPoint point = new On3dPoint();

            if (SampleCsRhinoScriptUtils.ConvertToOn3dPoint(pointObj, ref point))
            {
                MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();
                if (null != doc)
                {
                    MRhinoObject rhinoObj = doc.AddPointObject(point);
                    if (null != rhinoObj)
                    {
                        doc.Redraw();
                        return(rhinoObj.ModelObjectId().ToString());
                    }
                }
            }
            return(null);
        }