Pin & unpin of revit elements by worksets

Then I think you’ll need to look into a means of selecting that workset first and foremost. Search for “select workset” as a starting point.

This thread should get you started: Turn all worksets off, then one on