Esempio n. 1
0
        public static void CalculateLevelFromLevelBlockWithInvert()
        {
            HousingExtensionApplication.Current.Logger.LogCommand(typeof(LevelBlockCommands), nameof(CalculateLevelFromLevelBlockWithInvert));

            var doc = Application.DocumentManager.MdiActiveDocument;
            var db  = doc.Database;
            var ed  = doc.Editor;

            using var trans = db.TransactionManager.StartTransaction();

            if (!LevelBlockHelper.HasLevelBlock(db))
            {
                throw new ArgumentException(Resources.Exception_NoLevelBlock);
            }

            var start = LevelBlockHelper.GetPromptedBlockDetails(Resources.Command_Prompt_SelectStartLevelBlock, ed, trans);

            if (!start.IsValid)
            {
                return;
            }

            var invert = ed.PromptForDouble(Resources.Command_Prompt_EnterInvert, _invert);

            if (!invert.HasValue)
            {
                return;                   //Assume user cancelled
            }
            var endLevel = start.Level - invert.Value;

            var end = GenerateOrUpdateBlock(ed, db, new GenerateArgs(endLevel, start.Rotation, start.Rotate));

            if (!end.IsValid)
            {
                return;               //Assume user cancelled
            }
            if (ShouldIncludeGradient(ed))
            {
                GradientBlockHelper.GenerateBlock(db, start, end);
            }

            _invert = invert.Value;

            trans.Commit();
        }
        public static void CalculateGradientBetweenLevels()
        {
            HousingExtensionApplication.Current.Logger.LogCommand(typeof(GradientBlockCommands), nameof(CalculateGradientBetweenLevels));

            var doc = Application.DocumentManager.MdiActiveDocument;
            var ed  = doc.Editor;
            var db  = doc.Database;

            using var trans = db.TransactionManager.StartTransaction();

            var details = CommandHelper.GetStartEndDetails(ed, trans);

            if (details.IsValid)
            {
                GradientBlockHelper.GenerateBlock(db, details.Start, details.End);
                trans.Commit();
            }
        }