Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contextGeometries"></param>
        /// <param name="distanceCriteria"></param>
        /// <returns></returns>
        public Autodesk.DesignScript.Geometry.DSGeometry[] SelectWithinDistance(DSGeometry[] contextGeometries, double distanceCriteria)
        {
            if (contextGeometries == null)
            {
                throw new System.ArgumentNullException("contextGeometries");
            }
            else if (contextGeometries.Length == 0)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZero, "number of context geometries"), "contextGeometries");
            }

            var absDist = Math.Abs(distanceCriteria);

            List <DSGeometry> selectedGeoms = new List <DSGeometry>();

            foreach (var geom in contextGeometries)
            {
                double distance = geom.GeomEntity.DistanceTo(PointEntity);
                if (DSGeometryExtension.LessThanOrEquals(distance, absDist))
                {
                    selectedGeoms.Add(geom);
                }
            }

            return(selectedGeoms.ToArray());
        }