Hello everybody!
Is there really no way to delete a workset yet? Or may be some workaround?
It's a great pity if it's true. Moreover being able to create new worksets. The other issue is that there is even no way to move an object from one workset to another (no set property or method). I'm a right?
I found this dynamo forum on the topic of assigning worksets, They set the workset using the set parameter by name node, and it looks like the same is possible via the API. Looking at a terminal unit family it definitely has the parameter "workset" which is not read-only. Built-in parameter ELEM_PARTITION_PARAM. So you'd just assign it the same way you'd modify any parameter.
You can create new worksets with workset.create. See this forum post: http://forums.autodesk.com/t5/revit-api-forum/is-possible-create-workset-from-api/td-p/5830101
Check out the Workset and WorksetTable classes in the API documentation for more info on the methods being used.
am i overlooking something? What about the worksets button? The make the workset Editable, then delete.
Hello.
Currently there is no a way to delete worksets via API, but I have found a request in Autodesk Revit Ideas where you can vote and get it implemented:
https://forums.autodesk.com/t5/revit-ideas/delete-worksets-from-revit-api/idi-p/7575512
So, if you are still interested, please vote.
Thanks!
I found a way to delete the worksets in Revit. You first need to open up the workset dialog box and select the workset that you want to delete and make it editable. Then close the dialog box. If you don't close the dialog box before you select delete it will give you the error that revit cannot delete workset because it has been made editable. If you now close the dialog box and then reopen it again. That workset will still be editable but you can now delete that workset. You just have to make sure you close down the workset dialog box after you make it editable before deleting. It really sucks that Revit doesn't make this easier but this is how you delete a workset in Revit 2018 at least.
Thanks,
Brian Jones
This is the Revit API Forum. We are talking about deleting worksets programatically, not manually.
Dear all,
I just re-checked with the development team, and there is still no way to delete a workset.
Question: how can I programmatically delete a workset? Thank you!
Answer: No way to delete a workset and no workaround as well.
I double-checked the code and just not exposed... here is a development ticket for it:
Sorry for the bad news.
Please vote for the wish list entry in the Revit Idea Station.
Thank you!
Best regards,
Jeremy
whatever you need to delete by the API, you must have the id of the elements and a transaction.
here a simple code for elements in list, you will have to modify it for a single element.
hope that help
import clr
# 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 *
doc = DocumentManager.Instance.CurrentDBDocument
els = UnwrapElement(IN[0])
# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for i in els:
doc.Delete(i.Id)
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
#Uncomment the line below to output an object
OUT = "done!"
Could you please confirm if your script works for Workset elements?
It seems that the Document.Delete Method works with ElementId but not with the Workset Id Property.
Thanks a lot in advance.
Can't find what you're looking for? Ask the community or share your knowledge.