Revit API FamilySymbol can be actually renamed as duplicated name Bug?
Phenomenon
I've found out that Autodesk.Revit.Exceptions.ArgumentException is not thrown when trying to rename FamlySymbol.Name, so that familysymbols can be able to own duplicated name.
Code :
[Transaction(TransactionMode.Manual)]
public class FamilyDuplicate : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Boilerplate Variables
var uiapp = commandData.Application;
var app = uiapp.Application;
var uidoc = uiapp.ActiveUIDocument;
var doc = uidoc.Document;
var currentSelection = uidoc.Selection;
//First, I caught this when I tried renaming of FamilySymbol. But it also occured when the target instance is parent class.
var symbol = doc.GetElement(currentSelection.GetElementIds().First());
try
{
using (var tr = new Transaction(doc, "Rename Duplication Test"))
{
tr.Start();
symbol.Name = "300x300";
tr.Commit();
}
}
catch (Exception ex)
{
TaskDialog.Show("Rename Error", ex.Message);
return Result.Failed;
}
return Result.Succeeded;
}
}
Product : Revit 2024's API
---
GUESS
I've found that the inherited property from ElementType class has no Exception catching rule.
But the parent class of this (Element) has exception throw rule.
But when I tried the renaming of Element instance, it was same with familysymbol, no exception thrown.
---
Suggestion
It would be better when renaming via API, the exception occurs for prevent of creating duplicated name of familysymbol if the add-in creates new familysymbol.
0
votos