AttributeError: can't assign to read-only property Name of type 'Category'

Hi All,

Apologies for my complete lack of Python ability…

Short version, could someone help me fix the error;
‘AttributeError: can’t assign to read-only property Name of type ‘Category’’

Any advice gratefully received… :slight_smile:

#thanks to Archi-lab & bimorph.  Apologies for butchering your code.

import clr
from Autodesk.DesignScript.Geometry import *

#import ToDSType(bool) extension method
import Revit

#import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

#import Revit API
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
lineStyle = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines)
lineStyleSubTypes = lineStyle.SubCategories

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
listNames = []

for i in IN[0]:
    listNames = lineStyleSubTypes    
values = IN[1]

for i, j in zip(listNames, values):
    i.Name = j

#Assign your output to the OUT variable.
OUT = lineStyleSubTypes

Long version…

I’m trying to manage line style names through Dynamo.

I’ve read extensively through the forum and found the topic here…

Which advises to use the method here…

This is fine, I’ve put it all together, but got stuck at setting the name parameter, seemingly this is failing because Line Styles are a Sub-Category of lines.

I can’t see any nodes which might help, so jumped to Python trying to use the same method as the bimorph node LineStylesAttributes… Unfortunately I am no good at Python :frowning:

I’ve attached the graph for reference.



Line Styles.dyn (23.6 KB)

Hi Mark,

I am sorry for digging out this topic, I know it’s quite a while ago. I am just wondering, have you found out a way to rename linestyles, I mean not the builtin linestyles, but the others users create. I did a bit researches, however haven’t success yet.

Many Thanks.


Hi Ben,

I tried a more simple example where I used the same ‘method’ as to set filled regions names…

You can see the error message.

I’m afraid my knowledge is still not good enough!

I reviewed an example here…

But I couldn’t get it to work! perhaps you will have more success…

I couldn’t return a value for their cat.Id -> Doc.GetElement(eid) -> Type.Name

The use of StringBuilder is interesting, FYI you can import it with
import System.Text.StringBuilder as strBuilder



Yes, I got the same error too. The topic you shared is interesting, I am gonna have a try again. Anyway thanks Mark, much appreciate.