user3451925
user3451925

Reputation: 33

How to change Revit 2014 element name by API C#

I want to change element name by API and I have the following code.

Reference r = docUI.Selection.PickObject(ObjectType.Element, "Please pick an element");
Element element = doc.GetElement(r.ElementId);

element.Name = "MyElement";

But why occured this error ? 'This element does not support assignment of a user-specified name.' Or should I change the name by another way ?

Please help!

Upvotes: 1

Views: 1035

Answers (3)

Mahmoud AbdElMoneam
Mahmoud AbdElMoneam

Reputation: 76

I believe you have to change the Element Type to change its Name. Something like the following:

element.ChangeTypeId(anotherElementTypeId);

Upvotes: 1

mtumminello
mtumminello

Reputation: 169

Element names can't be changed. If you are actually looking to change the name of the element "type", that is editable.

Upvotes: 3

lznt
lznt

Reputation: 2576

The Name of an element is read-only and not supposed to be changed.

Upvotes: 0

Related Questions