Check if Sheet is blocked by other user

Hello Dynamo Friends :slight_smile:

I want to set parameters of sheets.

For sheets that are blocked by other users I would like to throw an error message.

The problem is that I can not catch the error and also the result of .Set() always returns True, no matter if it works or fails. Is there any way to check if the sheet is accessible before setting the parameter?

def update_parameter(sheet, param, param_name, current_value, new_value):

    t = Transaction(doc, "Set Sheet Parameter")
    t.Start()
    try:
        print("Attempting to update: " + sheet.Name)
        success = param.Set(new_value)
        if success:
            print("Updated: " + sheet.Name + " for " + param_name + " from " + str(current_value) + " to " + str(new_value))
        else:
            print("Update failed: " + sheet.Name + " for " + param_name)
        t.Commit()
    except Exception as e:
        print("ERROR: " + sheet.Name + " for " + param_name + " from " + str(current_value) + " - Exception: " + str(e))
        t.RollBack()

I think you’d have to check and see if the element is owned by anyone else at that time. See if this gets you what you’re after.
api - Revit Worksharing Checkout Status - Stack Overflow

3 Likes

Tricky, on first try i got OwnedByCurrentUser for all sheets, because I was calling it inside a transaction.

Without transaction it works fine :slight_smile: Thanks Nick!