/// <summary>
        /// This operation will cycle to the next solution for the last limit function. To accept call AcceptLimit.
        /// </summary>
        /// <param name="entityToLimit">The entity to limit.</param>
        /// <remarks></remarks>
        public static void NextSolution(IPSLimitable entityToLimit)
        {
            _powerSHAPE.DoCommand("NEXT SOLUTION");

            // Doing this changes the id but the name stays the same so get the new ID
            ((PSEntity)entityToLimit).Id =
                _powerSHAPE.ReadIntValue(((PSEntity)entityToLimit).Identifier + "['" + ((PSEntity)entityToLimit).Name +
                                         "'].ID");
        }
        /// <summary>
        /// Does not work as created.number is not updated.
        /// </summary>
        /// <param name="entityToLimit">The entity to limit.</param>
        /// <param name="keepOption">Keep option, by default KeepOne.</param>
        /// <returns>The limited entity.</returns>
        /// <remarks></remarks>
        internal static PSEntity LimitEntityUsingDynamicCutter(
            IPSLimitable entityToLimit,
            LimitingKeepOptions keepOption = LimitingKeepOptions.KeepOne)
        {
            // Get PowerSHAPE instance
            _powerSHAPE = ((PSEntity)entityToLimit).PowerSHAPE;

            // Create a list of the single entity
            PSEntity entity = (PSEntity)entityToLimit;

            _powerSHAPE.ActiveModel.ClearCreatedItems();

            entity.AddToSelection(true);

            _powerSHAPE.DoCommand("EDIT SELECTION");
            _powerSHAPE.DoCommand(keepOption.ToString());

            _powerSHAPE.DoCommand("Cutter_Dynamic On");

            bool    limitingHappened = false;
            PSModel model            = _powerSHAPE.ActiveModel;
            var     interval         = 1000;

            // Keep looping and picking points
            while (limitingHappened == false)
            {
                // Wait for a second to see if a limit has happened yet.  The item will no longer be selected when it has
                System.Threading.Thread.Sleep(interval);

                // See if the user finished creating the curve yet
                int selectedCount = 1;
                try
                {
                    selectedCount = _powerSHAPE.ReadIntValue("SELECTION.NUMBER");
                }
                catch
                {
                    selectedCount = 1;
                }
                if (selectedCount == 0)
                {
                    foreach (PSEntity newEntity in _powerSHAPE.ActiveModel.CreatedItems)
                    {
                        newEntity.Id = _powerSHAPE.ReadIntValue(newEntity.Identifier + "['" + newEntity.Name + "'].ID");
                        _powerSHAPE.ActiveModel.Add(newEntity);
                    }
                    limitingHappened = true;
                }
            }

            // When the limit happens we get a new entity with a new id but it has the same name as the original
            // So change the id of the entity we wanted to limit so things work as normal
            entity.Id = _powerSHAPE.ReadIntValue(entity.Identifier + "['" + entity.Name + "'].ID");

            return(entity);
        }
        /// <summary>
        /// Limits a single entity using a list of entities.
        /// </summary>
        /// <param name="entityToLimit">The entity on which to perform the limiting operation.</param>
        /// <param name="limitingEntities">The entities with which to perform the limiting operation.</param>
        /// <param name="limitingMode">The mode in which to carry out the operation.</param>
        /// <param name="keepOption">Whether to keep one or both sides of the limit.</param>
        /// <param name="trimOption">Whether to trim one or all of the entities.</param>
        internal static List <PSEntity> LimitEntity(
            IPSLimitable entityToLimit,
            List <PSEntity> limitingEntities,
            LimitingModes limitingMode     = LimitingModes.LimitMode,
            LimitingKeepOptions keepOption = LimitingKeepOptions.KeepOne,
            LimitingTrimOptions trimOption = LimitingTrimOptions.LimitOne,
            bool finishOperation           = true)
        {
            // Create a list of the single entity
            List <IPSLimitable> entitiesToLimit = new List <IPSLimitable>();

            entitiesToLimit.Add(entityToLimit);

            // Carry out limit operation
            return(LimitEntities(entitiesToLimit, limitingEntities, limitingMode, keepOption, trimOption, finishOperation));
        }