Пример #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);
        }
Пример #2
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);
        }
        /// <summary>
        /// Convert an object to an On3dPointArray
        /// </summary>
        static public bool ConvertToOn3dPointArray(object pointsObj, ref On3dPointArray points)
        {
            bool  rc          = false;
            int   pointsCount = points.Count();
            Array pointsArr   = pointsObj as Array;

            if (null != pointsArr)
            {
                for (int i = 0; i < pointsArr.Length; i++)
                {
                    On3dPoint point = new On3dPoint();
                    if (SampleCsRhinoScriptUtils.ConvertToOn3dPoint(pointsArr.GetValue(i), ref point))
                    {
                        points.Append(point);
                    }
                }
                rc = (points.Count() - pointsCount > 0);
            }
            return(rc);
        }