How to create custom .BuiltInFailures handling method

How to create custom .BuiltInFailures handling method

Anonymous
Not applicable
700 Views
1 Reply
Message 1 of 2

How to create custom .BuiltInFailures handling method

Anonymous
Not applicable

Hello,

 

I am working on a plugin that will import a number of drafting views from another project file. At first glance, what I am trying to achieve is very similar to the built in functionality of Insert from File > Insert Views from File. My ultimate goal is to add some much needed functionality to this built in feature. 

 

So far I have been able to successfully import as many views as I want from another project. After I import the first view I will get a Revit warning message indicating the following: 

Type "[Name]" has been renamed to "[New Name]" to avoid conflicts with the existing Element. 

 

I have figured out how to suppress this warning through the Revit API SDK:

 

    class HidePasteDuplicateTypesPreprocessor : IFailuresPreprocessor
    {
        #region IFailuresPreprocessor Members

        /// <summary>
        /// Implementation of the IFailuresPreprocessor.
        /// </summary>
        /// <param name="failuresAccessor"></param>
        /// <returns></returns>
        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
        {
            foreach (FailureMessageAccessor failure in failuresAccessor.GetFailureMessages())
            {
                // Delete any "Can't paste duplicate types.  Only non duplicate types will be pasted." warnings
                if (failure.GetFailureDefinitionId() == BuiltInFailures.CopyPasteFailures.CannotCopyDuplicates)
                {
                    failuresAccessor.DeleteWarning(failure);
                }

                if (failure.GetFailureDefinitionId() == BuiltInFailures.CopyPasteFailures.ElementRenamedOnPaste)
                {
                    failuresAccessor.DeleteWarning(failure);
                }
            }

            // Handle any other errors interactively
            return FailureProcessingResult.Continue;
        }

        #endregion
    }

This leaves my Revit model with an undesirable amount of duplicate detail groups. What I would like to do is have my code first recognize that the detail group already exists. If the detail group does exist, then re-use that detail group instead of trying to copy/paste a new instance.

 

Is there a simple solution to this?

The only thing I can think of would be to essentially rewrite a large portion of the SDK sample to check the existence of a detail group before it is copied.

From there I guess I would need to get the location of the detail group in the original view, and make sure it gets inserted into the same location of the new view. 

 

Thanks

0 Likes
701 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Dear Pat,

 

Thank you for your query.

 

Congratulations on implementing what you already have.

 

That sounds quite impressive.

 

I cannot say much more than agree with the direction you suggest, checking the existence of a detail group before it is copied and ensure it gets inserted in the proper location in the new view.

 

I hope this helps.

 

Maybe you are already done by now?

 

Good luck!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes