Issue with Setting ELEM_PARTITION_PARAM in Revit 2024 API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I am having an issue with my Revit plugin, which is designed to apply floor finishes to preselected rooms. This plugin works fine in Revit 2022, but I am facing problems in 2024 due to changes in the API.
The function I included below is where the problem exists. Simply it is used to create a new finish floor. The problem arises at the end of the function when trying to set wsparam, which gets the built-in paramerter for ELEM-PARTITION_PARAM.
def make_floor(new_floor):
# Start a transaction
t1 = Transaction(doc, 'create finish floor')
t1.Start()
floor_curves = CurveArray()
for boundary_segment in new_floor.boundary:
floor_curves.Append(boundary_segment.GetCurve())
# Variables
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
# New floor created
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.")
# Ok
wsparam = newfloorfinish.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM)
# Problem is here
wsparam.set(sharedGridWorksetId)
t1.Commit()
In my plugin code, the sharedGridWorkSetId is set to zero if there are no collaborators. I've tried setting that 0 as so ElementId(0) but that didn't work, neither did omitting setting the sharedGridWorksetId too.
Is there a better way to set the sharedGridWorksetId which is the user's WorkSetId? Or, is there a different workaround?