Pin & unpin of revit elements by worksets

Please see the below workflow. I tried to create a workflow for pin / unpin of the revit elements by extracting the elements from the worksets, The script is not excuted and there might be some problem, Please advise

The problem is due to your 3rd node in the string.

However before you fix that, are you aware this is going to pin or unpin EVERYTHING in the model as you haven’t yet reduced the workset collection? Some of the resulting items might not be pinnable either (i.e. the workset collection node might be returning stuff like your project browser).

I also believe that the 3 rd node is a problem for the execution, I got stuck here. Is there any alternative node for that or any other different workflow,

I can’t tell you what the node is, so i can’t tell you what the issue is.

Do you really want to try and pin EVERYTHING, or are you looking to reduce that workset list?

For example : There are 20 workests in my current document, I want to select a specific workset so calling the elements associated with that specific workset and then pin / unpin shall be done. This is what I want to done in the above script

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

hi @Boopalan.M82E8U you have 20 user created workset the node give 64, try filter for only user created as i think Jacob mean as well…

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk

clr.AddReference("RevitNodes")
import Revit
from Autodesk.Revit.DB import *
clr.ImportExtensions(Revit.Elements)

uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
doc = DocumentManager.Instance.CurrentDBDocument

refresh = IN[0] if len(IN) > 0 else False

userWorksets = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset)

names, ids, worksets = [], [], []

if userWorksets:
    if refresh:
        for workset in userWorksets:
            names.append(workset.Name)
            ids.append(workset.Id.IntegerValue)
            worksets.append(workset)
else:
    names.append("No worksets found")
    ids.append(None)
    worksets.append(None)

OUT = names, ids, worksets

and elements on these workset can still give you result you dont expect maybe, lets say a duct, it will give you the duct oc. but also mechinical system etc basic all there belong to your workset…so again filter that down so only select duct so you can pin

so maybe another way around could be select elements instead and filter for the workset name /id and pin

What is the purpose of pining elements by workset? Can set workset(s) no editable solve your problem?

@c.poupin Makes sense , will try in that way, I just tried to pin the elements by the workset order by automating it .

It depends what you want to do- pinning is ok for preventing accidental changes, but it is also easy to override

For stuff that you really don’t want anyone to modify (like grids or levels) it can be better to check out the workset, and not relinquish it