
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I create a function to load an specific TextType, needed on my addin.
Here's what the function does
- First the function validates that the name of the text type exist on the current project
- If it doesn't exist the addin copy from a resource a base Revit project file that contains the text type, and open it.
- Once opened it search for the TextType and copied with the method ElementTransformUtils.CopyElements to the current Revit Project.
- Finally the base Revit project is closed
It works fine, but each time the TextType is copied I received a warning message saying the following Types already exist but are different.
And show the following details
Arrow 30 Degree
Arrowhead: Arrow 30 Degree.
Since I'm not copying those elements I would like to remove the message.
Searching on the Revit documentation I found that the CopyPasteOptions could remove it, using the SetDuplicateTypeNamesHandler method that uses IDuplicateTypeNamesHandler, but I haven't found how to implement that interface.
I'll appreciate any help
Thanks
Here is the snippet of my function
internal static void LoadTextTypes()
{
FilteredElementCollector textNoteTypes = new FilteredElementCollector(Revit_App.RevDef.RevitDoc);
textNoteTypes.OfClass(typeof(TextNoteType));
var type = from text in textNoteTypes
where text.Name == "Vialdi Text"
select text as TextNoteType;
if (type.Count() > 0)
return;
string path = System.IO.Path.Combine(Revit_App.App.AppDirectory.FullName, "baseProject.rvt");
System.IO.File.WriteAllBytes(path, Media.BaseProject);
Document baseDocument = Revit_App.RevDef.RevitApp.OpenDocumentFile(path);
textNoteTypes = new FilteredElementCollector(baseDocument);
textNoteTypes.OfClass(typeof(TextNoteType));
type = from text in textNoteTypes
where text.Name == "Vialdi Text"
select text as TextNoteType;
List<ElementId> textTypes = new List<ElementId>();
textTypes.Add(type.First().Id);
Transaction tra = new Transaction(Revit_App.RevDef.RevitDoc, "copy");
tra.Start();
ElementTransformUtils.CopyElements(baseDocument, textTypes, Revit_App.RevDef.RevitDoc, null, new CopyPasteOptions());
tra.Commit();
baseDocument.Close();
}
And here is the warning message
Solved! Go to Solution.