Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66666

How to create custom .BuiltInFailures handling method

$
0
0

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


Viewing all articles
Browse latest Browse all 66666

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>