The purpose of this plugin is to be able to have the user select rooms, where their floors are assigned a finish floor based on already premade finish floors.
I had to update plugin code from 2022 to 2024, and this had me redoing snippet codes when it came to creating floors. In the past code, at the end of the floor making routine, we had to set our builtin parameters. This is where the code breaks.
def make_floor(new_floor):
t1 = Transaction(doc, 'Create a finish floor')
t1.Start()
floor_curves = CurveArray()
#Accessing room boundary property? and copying data into CurveArray
for boundary_segment in new_floor.boundary:
#Copy of curve to maintain intgretity especially since we started a transaction
floor_curves.Append(boundary_segment.GetCurve())
#variables for the new floor
floorType = doc.GetElement(new_floor.type_id)
level = doc.GetElement(new_floor.level_id)
normal = XYZ.BasisZ
collector = FilteredElementCollector(doc)
viewFamilyTypes = collector.OfClass(ViewFamilyType).ToElements()
floorPlanId = ElementId.InvalidElementId
for e in viewFamilyTypes:
if isinstance(e, ViewFamilyType) and e.ViewFamily == ViewFamily.FloorPlan:
floorPlanId = e.Id
break
newfloorfinish = ViewPlan.Create(doc, floorPlanId,level.Id)
level_elevation_param = level.get_Parameter(BuiltInParameter.LEVEL_ELEV)
if level_elevation_param:
level_elevation_param.Set(level_elevation_param.AsDouble() + floorthickness)
else:
print("Parameter LEVEL_ELEV not found")
#variables for log
def message(note, error):
return "\n {}: {}\n".format(note, error)
def annotation(note, error):
with open(base_dir + "\log.txt", "a") as file:
file.write(message(note, error))
wsparam = newfloorfinish.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM)
wsparam.Set(0);
annotation(1,"no more candy in the shop")
t1.Commit()
The contentious code is here
wsparam.Set(0);
The error says that you cannot modify read only parameters, for zero represents the worksetid.
Any help would be helpful.