Workset Editability

My Python script works in IronPython2.7 and if you send in a flat list of worksets. I have tested it. If you are using it this way it is likely something specific to your project, for example you cannot check out a workset as another user already is using it.

I understand there may be problem with version and i was looking for controlling Ediatble & Non-Editable tabs in workset for the purpose of assigning my name in “Project Info” in Project Standards. so, no one cannot move the project coordinates without my permission.
image
image
if you have any nodes related to it let me know as well i am following your “crumple” so if you add in “Crumple” package it will be helpful for everyone.

thank you

In that case they are different types of worksets and I am unsure if they are accessible in the same way.

I tested them using the WorksetKind ‘UserWorkset’:

My node in Crumple called ‘Collect.Worksets’ retrieves those worksets by the kind.

Checkout of other types of worksets might be locked off or not safe to check out this way as they are typically managed behind the scenes by Revit to my understanding.

If you break the code out of the try/except and just run it in the main script body it might reveal why it doesnt work in an error message.

This is a GREAT way to corrupt a model and take a team offline or force a recovery to a prior version. Train your users and monitor the location and you’ll come out ahead.

Thanks for your input! I’m diving deep into learning Dynamo for Revit. While working on a script for worksets, I found many others are looking for answers too. Python scripts haven’t worked out for me, so I’m hopeful that someone creates a dedicated node for PROJECT STANDARDS IN WORKSET. It could really quench the thirst for knowledge in this area!

That is an incredibly specific node, it likely wont happen. Better that you learn how to access a workset of that kind. A filteredworksetcollector using the ofkind method can do the trick.

Seconding Jacob’s recommendation to test it carefully…

Testing usually won’t show anything wrong. It’s sort of like how when you test it looks like you can use OneDrive to hose your central files and allow remote collaboration, until you try it in production and suddenly you start seeing corruption warnings.

using onedrive will definitely hose a central file! :rofl:

Yep.

I had to explain why ‘the test you ram by saving one file and using it yourself for two syncs wasn’t a valid test’ about once every 2 minutes when the pandemic hit and everyone shifted to work from home.

I will encourage this completely taboo behaviour.

This script can.

  1. Sync your model
  2. Find all worksets containing a criteria as a name “In your case Project Info” i guess?
  3. Checkout those worksets.

You can go full ham and corrupt the heck out of anything with this badboy by always using it to sync your model instead of the regular sync options, you will remain the owner of the specified worksets… you greedy boi.

I take no responsibilty for any adverse impacts of this.
In your recreation, remove the code block after the worksetbyname node and tap it straight into the checkout node.

Sync with Central
# Made by >         Max Fasher
# Dynamo Forum >    https://forum.dynamobim.com/u/pyxam
# Linkedin >        https://www.linkedin.com/in/max-fasher/

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

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

relStandardWS = True
relViewWS = True
relFamWS = True
relUserWS = True
relCheckedOutElems = True
compact = False
saveLocalBefore = True
saveLocalAfter = True
comment = ""
runme = True

if runme:
	doc = DocumentManager.Instance.CurrentDBDocument
	tOptions = TransactWithCentralOptions()
	rOptions = RelinquishOptions(False)
	rOptions.StandardWorksets = relStandardWS
	rOptions.ViewWorksets = relViewWS
	rOptions.FamilyWorksets = relFamWS
	rOptions.UserWorksets = relUserWS
	rOptions.CheckedOutElements = relCheckedOutElems
	sOptions = SynchronizeWithCentralOptions()
	sOptions.SetRelinquishOptions(rOptions)
	sOptions.Compact = compact
	sOptions.SaveLocalBefore = saveLocalBefore
	sOptions.SaveLocalAfter = saveLocalAfter
	sOptions.Comment = comment
	TransactionManager.Instance.ForceCloseTransaction()
	try:
		doc.SynchronizeWithCentral(tOptions, sOptions)
		OUT = True
	except:
		OUT = False
else: OUT = False
Workset Filter By Name
# Made by >         Max Fasher
# Dynamo Forum >    https://forum.dynamobim.com/u/pyxam
# Linkedin >        https://www.linkedin.com/in/max-fasher/

#====================================================================#
#Imports

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk

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

#====================================================================#
#Inputs

SearchSTR = str(IN[0]) #Criteria for which to search for Template

#====================================================================#
#Variables

inputdoc    = DocumentManager.Instance.CurrentDBDocument
doc         = DocumentManager.Instance.CurrentDBDocument

collector   = FilteredWorksetCollector(doc) #Workset Collector
names       = [] #List of Workset Names

#====================================================================#
#Filtering

names = [ws.Name for ws in collector.ToWorksets()]

#Use me if you want to contain this within the Python Script (Instead of an Input option)

##filtered_worksets = [ws for name, ws in zip(names, collector) if "View ##Template" in name]

#OUT = names, collector.ToWorksets()
filtered_worksets = [ws for name, ws in zip(names, collector) if SearchSTR  in name]

OUT = filtered_worksets
Workset Checkout
# Made by >         Max Fasher
# Dynamo Forum >    https://forum.dynamobim.com/u/pyxam
# Linkedin >        https://www.linkedin.com/in/max-fasher/

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

# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# Import system library
clr.AddReference('System.Core')
from System.Collections.Generic import *

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

def ToList(x):
    if isinstance(x,list):
        return UnwrapElement(x)
    else:
        return [UnwrapElement(x)]

worksets = ToList(IN[0])
iDs = [ws.Id for ws in worksets]
Ids = List[WorksetId](iDs)
try: checkedout_ws = WorksharingUtils.CheckoutWorksets(doc,Ids)
except Exception,e: checkedout_ws = str(e)
OUT = checkedout_ws
1 Like

3 Likes

I guess it won’t work. as you mentioned code as VIEW TEMPLATE in that definitely you will get workset but its USER WORKSET not a PROJECT STANDARDS WORKSET. i am here talking about PROJECT STANDARD WORKSET.



image
image

for this we need try out of VIEW TEMPLATE. (I am asking these doubts for learning process; while learning dynamo, this concept made me curious, so I am digging :sweat_smile:)

but thank you guys each and every one for responding.

You need to read my message more carefully, where i have view template you can change to project info.

I tried PROJECT INFO but I faced some errors. so, I thought it only works for user workset. I apology for that. let me show you the errors.

That is all.

it is working with one parameter.
what if we have multiple parameters?

Regards,