Hi everyone.
Revit 2019, Dynamo 2.0.3.8810.
Im trying to create python script for dynamo, that will change elements workset, but when i run my code in dynamo im getting error:
Traceback (most recent call last):
File string, line 43, in module
Exception: The parameter is read-only.
In the code im getting Id of specific workset, then creating list of elements and finally trying to change the workset for these elements.
My code:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit import DB
from Autodesk.Revit.DB import *
clr.AddReference("System")
import System
from System.Collections.Generic import List
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager as TM
doc = DocumentManager.Instance.CurrentDBDocument
workset_collector = FilteredWorksetCollector(doc)
ws = ''
for c in workset_collector:
if c.Name == "10_Structure":
ws = c.Id.IntegerValue
filter = DB.ElementMulticategoryFilter(
List[DB.BuiltInCategory]([
DB.BuiltInCategory.OST_Walls,
DB.BuiltInCategory.OST_Floors,
DB.BuiltInCategory.OST_GenericModel,
DB.BuiltInCategory.OST_Stairs,
DB.BuiltInCategory.OST_Columns,
DB.BuiltInCategory.OST_StructuralColumns
]),
False
)
elements = DB.FilteredElementCollector(doc).OfClass(FamilyInstance).WherePasses(filter)
with Transaction(doc, 'Workset change') as t:
t.Start()
for element in elements:
parameter = element.Parameter[BuiltInParameter.ELEM_PARTITION_PARAM]
parameter.Set(ws)
t.Commit()
OUT = elements
Is there a way to change “read-only parameter”?
UPD: It seems there is a problem with complex families like stairs.