Hope I understood your question correctly… you want to have 3D views in Revit showing only elements from each workset?!
If that’s the case, then the following definition takes elements, sorts them by their workset, creates 3D views using each workset name, and then Isolates elements within their respective view.
If that’s was not what you are after, let me know and I will try to help out.
Solution exception:Starting a new transaction is not permitted. It could be because another transaction already started and has not been completed yet, or the document is in a state in which it cannot start a new transaction (e.g. during failure handling or a read-only mode, which could be either permanent or temporary).
Can I assign a new created workset to an element or switching workset to be assigned to the element? or is just a one off workset application?
If you are chaining these scripted components it will get confused on the transactions. Best to do one off operations until there are native workset components.