Hello,
I create a function to load an specific TextType, needed on my addin.
Here's what the function does
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.
Solved by arnostlobel. Go to Solution.
Hello Miguel Alanis:
I believe the problem is caused by the existence of nested families (types) referenced by the text type you attempt to copy. In other words, you do copy a type that does not exist yet, but which contains other nested types that do exists already in the target document, either as standalone or nested in other families.
In your particular case it seems you do not worry about that, therefore you should simply set the copy option to ignore such cases, meaning you give it an instance of your custom IDuplicateTypeNamesHandler.
CopyPasteOptions options = new CopyPasteOptions(); Options.SetDuplicateTypeNamesHandler(new MyCopyHandler());
Where the class MyCopyHandler is an implementation of the IDuplicateTypeNamesHandler, for example:
public MyCopyHandler : IDuplicateTypeNamesHandler { public DuplicateTypeAction OnDuplicateTypeNamesFound() { return DuplicateTypeAction.UseDestinationTypes; } }
(Note: I typed the above code directly in this post just to illustrate the case. Please make sure to adjust it so it compiles 😉
Thank you
Arnošt Löbel
Sr. Principal Engineer
Autodesk, Revit R&D
Can't find what you're looking for? Ask the community or share your knowledge.