If you are new to Python: it’s useful to get the hang of the hierachie of revit api (install RevitLookup if you haven’t already)
You slowly will go down the rabbit hole, but the quest is usually which path to take and which doors you have to open in order to get there.
In the link you shared I gave a little explaination how to set layer colors. I wrote for our company a script that converts autocad layer colors to revit since revit converts rgb to the nearest index color.
So to give you some hints: you can “ask” what else is possible in python.
selections = revit.get_selection()
for selection in selections:
layers = sorted(selection.Category.SubCategories, key=lambda x: x.Name)
for layer in layers:
lname = layer.Name
Basicly this loops through each layer. But be aware: you are looping through Revit’s Subcategories.
And it lname is set to layer.Name. Everything after the dot is something you can call. But “hey I’m new to python how do I know what to call?”
Use dir().
selections = revit.get_selection()
for selection in selections:
layers = sorted(selection.Category.SubCategories, key=lambda x: x.Name)
for layer in layers:
lname = layer.Name
print dir(layer) #this will show everything you can do with layer.
This will output something like this:
['AllowsBoundParameters', 'BuiltInCategory', 'CanAddSubcategory', 'CategoryType', 'Dispose', 'GetBuiltInCategory', 'GetBuiltInCategoryTypeId', 'GetCategory', 'GetGraphicsStyle', 'GetHashCode', 'GetLinePatternId', 'GetLineWeight', 'HasMaterialQuantities', 'Id', 'IsBuiltInCategory', 'IsBuiltInCategoryValid', 'IsCuttable', 'IsReadOnly', 'IsTagCategory', 'IsValid', 'IsVisibleInUI', 'LineColor', 'Material', 'Name', 'Parent', 'ReleaseManagedResources', 'ReleaseUnmanagedResources', 'SetLinePatternId', 'SetLineWeight', 'SubCategories', '__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
So to me SetLineWeight
looks promising.