Beispiel #1
0
        /// <summary>Array of Rhino Objects related to a Named Position.</summary>
        /// <param name="id">
        /// The Guid of the named position from which you want to retrieve the objects.
        /// </param>
        /// <returns>
        /// Array of Rhino Objects which are tracked by the Named Position.
        /// </returns>
        /// <since>6.0</since>
        public RhinoObject[] Objects(Guid id)
        {
            var objects = new Runtime.InternalRhinoObjectArray();

            UnsafeNativeMethods.RhNamedPosition_Objects(m_doc.RuntimeSerialNumber, id, objects.NonConstPointer());

            return(objects.ToArray());
        }
Beispiel #2
0
 /// <summary>
 /// Gets an array of all of the objects in a group.
 /// </summary>
 /// <param name="groupIndex">The index of the group in this table.</param>
 /// <returns>An array with all the objects in the specified group.</returns>
 /// <since>5.0</since>
 public RhinoObject[] GroupMembers(int groupIndex)
 {
     using (Rhino.Runtime.InternalRhinoObjectArray rhobjs = new Runtime.InternalRhinoObjectArray())
     {
         IntPtr pRhinoObjects = rhobjs.NonConstPointer();
         UnsafeNativeMethods.CRhinoGroupTable_GroupMembers(m_doc.RuntimeSerialNumber, groupIndex, pRhinoObjects);
         return(rhobjs.ToArray());
     }
 }
        /// <summary>
        /// Examines mesh objects and logs a description of what it finds right or wrong.
        /// The various properties the function checks for are described in MeshCheckParameters.
        /// </summary>
        /// <param name="meshObjects">A collection of mesh objects.</param>
        /// <param name="textLog">The text log.</param>
        /// <param name="parameters">The mesh checking parameter and results.</param>
        /// <returns>true if successful, false otherwise.</returns>
        /// <since>7.0</since>
        public static bool CheckMeshes(IEnumerable <MeshObject> meshObjects, Rhino.FileIO.TextLog textLog, ref MeshCheckParameters parameters)
        {
            if (null == textLog)
            {
                throw new ArgumentNullException(nameof(textLog));
            }
            var    rharray         = new Runtime.InternalRhinoObjectArray(meshObjects);
            IntPtr ptr_const_array = rharray.NonConstPointer();
            IntPtr ptr_textlog     = textLog.NonConstPointer();

            return(UnsafeNativeMethods.RHC_RhinoCheckMesh2(ptr_const_array, ptr_textlog, ref parameters));
        }
Beispiel #4
0
        /// <summary>
        /// Searches for locations where the distance from a RhinoObject, in one set of objects,
        /// is less than the specified distance to another RhinoObject in a second set of objects.
        /// This function uses the object's mesh to calculate the interferences.
        /// Acceptable object types include: BrepObject, ExtrusionObject, MeshObject, and SubDObject.
        /// </summary>
        /// <param name="setA">The first set of Rhino objects.</param>
        /// <param name="setB">The second set of Rhino objects.</param>
        /// <param name="distance">The largest distance at which a clash can occur.</param>
        /// <param name="meshType">The type of mesh to be used for the calculation.</param>
        /// <param name="meshingParameters">The meshing parameters used to generate meshes for the calculation.</param>
        /// <returns>An array of mesh interference object if successful, or an empty array on failure.</returns>
        public static MeshInterference[] Search(IEnumerable <RhinoObject> setA, IEnumerable <RhinoObject> setB, double distance, MeshType meshType, MeshingParameters meshingParameters)
        {
            using (var set_a_array = new Runtime.InternalRhinoObjectArray(setA))
                using (var set_b_array = new Runtime.InternalRhinoObjectArray(setB))
                {
                    var ptr_set_a        = set_a_array.NonConstPointer();
                    var ptr_set_b        = set_b_array.NonConstPointer();
                    var ptr_mp           = meshingParameters.ConstPointer();
                    var ptr_clash_events = UnsafeNativeMethods.RhObjectClashEventArray_New(); // new
                    var count            = UnsafeNativeMethods.RHC_CRhClashDetect_TestClash(ptr_set_a, ptr_set_b, distance, (int)meshType, ptr_mp, ptr_clash_events);

                    var rc = new MeshInterference[count];
                    for (var i = 0; i < count; i++)
                    {
                        var index_a        = -1;
                        var index_b        = -1;
                        var hit_points     = new SimpleArrayPoint3d(); // new
                        var ptr_hit_points = hit_points.NonConstPointer();
                        var mi             = new MeshInterference();
                        if (UnsafeNativeMethods.RhObjectClashEventArray_GetAt(ptr_clash_events, i, ref index_a, ref index_b, ptr_hit_points))
                        {
                            mi.IndexA    = index_a;
                            mi.IndexB    = index_b;
                            mi.HitPoints = hit_points.Count > 0 ? hit_points.ToArray() : new Point3d[0];
                        }
                        else
                        {
                            mi.IndexA    = -1;
                            mi.IndexB    = -1;
                            mi.HitPoints = new Point3d[0];
                        }
                        hit_points.Dispose(); // delete
                        rc[i] = mi;
                    }

                    UnsafeNativeMethods.RhObjectClashEventArray_Delete(ptr_clash_events); // delete
                    GC.KeepAlive(setA);
                    GC.KeepAlive(setB);
                    return(rc);
                }
        }
Beispiel #5
0
        /// <summary>Append objects to a Named Position.</summary>
        /// <param name="id">
        /// Guid of the Named Position which you want to append to.
        /// </param>
        /// <param name="objects">
        /// Collection of Rhino Objects to be included in this Named Position.
        /// </param>
        /// <returns>
        /// True or False depending on whether the Append was successful.
        /// </returns>
        /// <since>6.0</since>
        public bool Append(Guid id, IEnumerable <RhinoObject> objects)
        {
            var intObjects = new Runtime.InternalRhinoObjectArray(objects);

            return(UnsafeNativeMethods.RhNamedPosition_Append(m_doc.RuntimeSerialNumber, id, intObjects.NonConstPointer()));
        }
Beispiel #6
0
        /// <summary>Save a new Named Position.</summary>
        /// <param name="name">
        /// Name for this Named Position.
        /// </param>
        /// <param name="objects">
        /// Array of Rhino Objects which should be included in this Named Position.
        /// </param>
        /// <returns>
        /// Guid of the newly saved Named Position.
        /// </returns>
        /// <since>6.0</since>
        public Guid Save(string name, IEnumerable <RhinoObject> objects)
        {
            var intObjects = new Runtime.InternalRhinoObjectArray(objects);

            return(UnsafeNativeMethods.RhNamedPosition_Save(m_doc.RuntimeSerialNumber, name, intObjects.NonConstPointer()));
        }