コード例 #1
0
            public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
            {
                // inside event handler, get all warnings

                IList <FailureMessageAccessor> failures = a.GetFailureMessages();

                foreach (FailureMessageAccessor f in failures)
                {
                    // check failure definition ids
                    // against ones to dismiss:

                    FailureDefinitionId id = f.GetFailureDefinitionId();

                    if (BuiltInFailures.InaccurateFailures.InaccurateLine == id ||
                        BuiltInFailures.OverlapFailures.DuplicateInstances == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateCurveBasedFamily == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateBeamOrBrace == id ||
                        BuiltInFailures.InaccurateFailures.InaccurateLine == id)
                    {
                        a.DeleteWarning(f);
                    }
                    else
                    {
                        a.RollBackPendingTransaction();
                    }
                }
                return(FailureProcessingResult.Continue);
            }
コード例 #2
0
ファイル: dynUtils.cs プロジェクト: pterelaos/dynamo
        public FailureProcessingResult PreprocessFailures(
	        FailuresAccessor a)
        {
            // inside event handler, get all warnings

            IList<FailureMessageAccessor> failures
                = a.GetFailureMessages();

            foreach (FailureMessageAccessor f in failures)
            {
                // check failure definition ids
                // against ones to dismiss:

                FailureDefinitionId id
                    = f.GetFailureDefinitionId();

                //      BuiltInFailures.JoinElementsFailures.CannotKeepJoined == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructural == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructuralError == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsWarn == id

                if (BuiltInFailures.InaccurateFailures.InaccurateLine == id ||
                    BuiltInFailures.OverlapFailures.DuplicateInstances == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateCurveBasedFamily == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateBeamOrBrace == id
                    )
                {
                    a.DeleteWarning(f);
                }
                //else if(BuiltInFailures.CurveFailures.LineTooShortError == id ||
                //    BuiltInFailures.CurveFailures.LineTooShortWarning == id
                //    )
                //{
                //    a.RollBackPendingTransaction();
                //}
                else
                {
                    a.RollBackPendingTransaction();
                }

            }
            return FailureProcessingResult.Continue;
        }
コード例 #3
0
ファイル: dynUtils.cs プロジェクト: TCadorette/dynamo
        public FailureProcessingResult PreprocessFailures(
            FailuresAccessor a)
        {
            // inside event handler, get all warnings

            IList <FailureMessageAccessor> failures
                = a.GetFailureMessages();

            foreach (FailureMessageAccessor f in failures)
            {
                // check failure definition ids
                // against ones to dismiss:

                FailureDefinitionId id
                    = f.GetFailureDefinitionId();

                //      BuiltInFailures.JoinElementsFailures.CannotKeepJoined == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructural == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsStructuralError == id ||
                //    BuiltInFailures.JoinElementsFailures.CannotJoinElementsWarn == id

                if (BuiltInFailures.InaccurateFailures.InaccurateLine == id ||
                    BuiltInFailures.OverlapFailures.DuplicateInstances == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateCurveBasedFamily == id ||
                    BuiltInFailures.InaccurateFailures.InaccurateBeamOrBrace == id
                    )
                {
                    a.DeleteWarning(f);
                }
                //else if(BuiltInFailures.CurveFailures.LineTooShortError == id ||
                //    BuiltInFailures.CurveFailures.LineTooShortWarning == id
                //    )
                //{
                //    a.RollBackPendingTransaction();
                //}
                else
                {
                    a.RollBackPendingTransaction();
                }
            }
            return(FailureProcessingResult.Continue);
        }
コード例 #4
0
        /// <summary>
        /// This is an event handler that responds to a failure according to the current settings
        /// </summary>
        /// <param name="sender">The sending object, i.e. the Revit application</param>
        /// <param name="e">The event arguments</param>
        public void AutoOptionsFailureHandler(Object sender, Autodesk.Revit.DB.Events.FailuresProcessingEventArgs e)
        {
            //don't process if handling is turned off
            if (currentSettings.HandlingActive == false)
            {
                return;
            }

            //update the uiApp reference
            Application RevitApp = sender as Application;

            uiApp = new UIApplication(RevitApp);

            FailuresAccessor fa = e.GetFailuresAccessor();
            //this is the action that will be taken to attempt resolution. Default is to continue the default Revit failure processing
            FailureProcessingResult action = FailureProcessingResult.Continue;

            foreach (FailureMessageAccessor fma in fa.GetFailureMessages())
            {
                AutoFailureHandlingOptions aFOpts = currentSettings.AllFailureOptions
                                                    .Where(x => x.FailureGuid == fma.GetFailureDefinitionId().Guid)
                                                    .FirstOrDefault();

                if (aFOpts != null)
                {
                    //Show the CatchFailures dialog if a failure was caught
                    if (currentSettings.InteractiveModeEnabled)
                    {
                        try
                        {
                            //todo: clone to allow roll-back?
                            FailureCatcherWindow failWin = new FailureCatcherWindow(currentSettings, aFOpts, uiApp);

                            Boolean?result = failWin.ShowDialog();

                            if (result.Value)
                            {
                                //Write changes to the .ini
                                currentSettings.LastUpdate = DateTime.Now;
                                IAutoOptionsRepository settingsRepo = new AutoOptionsConfigFileRepo();
                                settingsRepo.WriteAutoOptions(currentSettings);
                            }
                        }
                        catch (Exception ex)
                        {
                            TaskDialog.Show("ex", ex.Message + "\n" + ex.StackTrace);
                            throw;
                        }
                    }

                    FailureResolutionOption selectedResolution = aFOpts.SelectedResolution;
                    if (selectedResolution is AutoOptionsResolution)
                    {
                        try
                        {
                            switch (((AutoOptionsResolution)selectedResolution).Resolution)
                            {
                            case AutoOptionsResolutionType.NoAction:
                                break;

                            case AutoOptionsResolutionType.DeleteAffected:
                                fa.DeleteElements(fma.GetFailingElementIds().ToList());
                                action = FailureProcessingResult.ProceedWithCommit;
                                break;

                            case AutoOptionsResolutionType.CancelTransaction:
                                //todo: not working, being overwritten?
                                action = FailureProcessingResult.ProceedWithRollBack;
                                e.SetProcessingResult(action);
                                fa.RollBackPendingTransaction();
                                return;

                            case AutoOptionsResolutionType.HideWarning:
                                //todo: check if actually is a warning?
                                fa.DeleteWarning(fma);
                                break;

                            default:
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            TaskDialog.Show("Dispatcher", ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
                        }
                    }
                    else if (selectedResolution is RevitResolution)
                    {
                        try
                        {
                            FailureResolutionType fRT = ((RevitResolution)selectedResolution).Resolution;

                            if (fma.HasResolutionOfType(fRT))
                            {
                                fma.SetCurrentResolutionType(fRT);
                                fa.ResolveFailure(fma);
                                action = FailureProcessingResult.ProceedWithCommit;
                            }
                            else
                            {
                                TaskDialog.Show("AutoOptions", "The selected automatic resolution \n***" + aFOpts.SelectedResolution.FriendlyCaption + " (" + fRT + ")***\ncan't be used");
                            }
                        }
                        catch (Exception ex)
                        {
                            TaskDialog.Show("Dispatcher", ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
                        }
                    }
                }
            }

            e.SetProcessingResult(action);
        }