Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
1399 Views, 6 Replies

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

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

 

 

 

6 REPLIES 6
Message 2 of 7
JimJia
in reply to: Anonymous

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
Message 3 of 7
FAIR59
in reply to: Anonymous

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;
Message 4 of 7
Anonymous
in reply to: FAIR59

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.

Message 5 of 7
FAIR59
in reply to: Anonymous

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
in reply to: FAIR59

 Still now joy: Throw New NotImplementedException()

Message 7 of 7
FAIR59
in reply to: Anonymous

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 ) .

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report