suppress warning > new warning with only 'cancel' button?

suppress warning > new warning with only 'cancel' button?

Anonymous
Not applicable
1,798 Views
6 Replies
Message 1 of 7

suppress warning > new warning with only 'cancel' button?

Anonymous
Not applicable

Hi,

 

In my model there are a few familyinstances with an aligned dimension attached to them. When I rotate one of these familyinstances I receive an error dialog: "Error - cannot be ignored. The References of the highlighted Dimension are no longer parallel." Now I have the option to click 'remove references' or click 'cancel' (the button 'ok' is inaccessible / grayed out). 'Remove references' removes the references and Revit continues. 

 

However when I try to suppress this warning (FailureDefinitionId = BuiltInFailures.DimensionFailures.LinearConstraintNotParallel) by using FailuresAccessor.delete(FailureMessageAccessor) in order to delete the references a new error dialog pops up. It is the same one as "Error - cannot be ignored. The References of the highlighted Dimension are no longer parallel" only without the button 'remove references'. Because the OK-button is not accessible I can only click 'Cancel' which rolles back previous transactions. Is there a way to get the warning suppressor to act like the 'normal user input'?

 

regards,

Raymond

 

 

 

0 Likes
1,799 Views
6 Replies
Replies (6)
Message 2 of 7

JimJia
Alumni
Alumni

Raymond,

 

If the IFailureProcessor doesn't solve your problem, you may try following approaches to suppress the dialog:

There are several different possible ways to suppress unwanted dialogues in Revit:

http://thebuildingcoder.typepad.com/blog/2010/08/suppress-unwanted-dialogue.html

 

Besides, we also can use windows API to suppress dialog, it's more powerful: 

http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html

 

Hope this is helpful.


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 3 of 7

FAIR59
Advisor
Advisor

this is not a warning, but an error, so it shouldn't be deleted. The error(s) must be Resolved, and the failureProcessingResult must be set.

 

try this:

            failuresAccessor.ResolveFailures(fmas);
            if (failuresAccessor.CanCommitPendingTransaction())
            {
                return FailureProcessingResult.ProceedWithCommit;
            }
            if (failuresAccessor.CanRollBackPendingTransaction())
            {
                return FailureProcessingResult.ProceedWithRollBack;
            }
            return FailureProcessingResult.Continue;
0 Likes
Message 4 of 7

Anonymous
Not applicable

thanks for the response but I have tried this solution already. When resolvefailures is hit the error window (as described) shows up immediately (before hitting the next codeline). It seems to me the error is defined, but has no implemented error handler. 

 

Dismissing the whole error window using the windows API seems a buggy and tricky solution to me.

0 Likes
Message 5 of 7

FAIR59
Advisor
Advisor

here is my test code that works Revit 2016 and 2018.

 

 

    public class ReferencesNotParallelSwallower : IFailuresPreprocessor
    {
        public FailureProcessingResult PreprocessFailures(FailuresAccessor a)
        {
            bool HasErrors = false;
            IList<FailureMessageAccessor> fmas = a.GetFailureMessages();

            if (fmas.Count == 0)
            {
                return FailureProcessingResult.Continue;
            }

            foreach (FailureMessageAccessor f in fmas)
            {
                FailureSeverity failureSeverity
                      = f.GetSeverity();
                if (failureSeverity == FailureSeverity.Error && f.GetFailureDefinitionId().Guid.ToString() == "8a9ff20d-fdc2-4f98-87e6-2aa8b71b0c83")
                {
                    HasErrors = true;
                }
            }
            if (!HasErrors)
            {
                return FailureProcessingResult.Continue;
            }
            a.DeleteAllWarnings();
            a.ResolveFailures(fmas);
            return FailureProcessingResult.ProceedWithCommit;
        }
    }

The most important lines are the last two lines.

 

Message 6 of 7

Anonymous
Not applicable

 Still now joy: Throw New NotImplementedException()

0 Likes
Message 7 of 7

FAIR59
Advisor
Advisor

this is a different issue altogether.

you probably have defined a DialogBoxShowing eventhandler, and not written any code in the body.

 

I expect you have a method somewhere that looks like this:

 

		void ThisApplication_DialogBoxShowing(object sender, DialogBoxShowingEventArgs e)
		{
			throw new NotImplementedException();
		}

remove the line  -- throw new NotImplementedException(); --( or the complete method ) .

0 Likes