How to delete a workset?

How to delete a workset?

WhiteSharx
Contributor Contributor
18,811 Views
18 Replies
Message 1 of 19

How to delete a workset?

WhiteSharx
Contributor
Contributor

Hello everybody!

 

Is there really no way to delete a workset yet? Or may be some workaround?

0 Likes
18,812 Views
18 Replies
Replies (18)
Message 2 of 19

devonpowell
Advocate
Advocate
Looking thru the documentation it does not look like deleting a workset is possible. At first, this sort of made sense, because everything needs to be on a workset, so if you deleted one it would cause issues. However, when you go through the UI, it lets you delete worksets and gives you the option to either delete elements OR move them to a new workset. It seems the API equivalent is missing.

The only "workaround" I see is renaming a workset using the WorksetTable.RenameWorkset method.

0 Likes
Message 3 of 19

WhiteSharx
Contributor
Contributor

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?

0 Likes
Message 4 of 19

devonpowell
Advocate
Advocate

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.

snoop params.PNG

 

 

Workset Parameter.PNG

 

 

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. 

Message 5 of 19

m.voss.alvine
Advocate
Advocate

am i overlooking something?  What about the worksets button?  The make the workset Editable, then delete.

 

worksets.png

Revit MEP 2015 Certified Professional
Revit Architecture 2015 Certified Professional
AutoCAD 2015 Certified Professional


remember to 'accept as solution' if this helped
Message 6 of 19

devonpowell
Advocate
Advocate
This isn't the API forum, so he is asking if there is a programmatic way to delete a work set.
0 Likes
Message 7 of 19

devonpowell
Advocate
Advocate
I meant it IS the API forum.
0 Likes
Message 8 of 19

Alvaro.PerezUzuriaga
Explorer
Explorer

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!

Message 9 of 19

bjones
Explorer
Explorer

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

 

Message 10 of 19

Alvaro.PerezUzuriaga
Explorer
Explorer

This is the Revit API Forum. We are talking about deleting worksets programatically, not manually.

0 Likes
Message 11 of 19

jeremytammik
Autodesk
Autodesk

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

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 12 of 19

Yien_Chao
Advisor
Advisor

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!"

 

0 Likes
Message 13 of 19

Yanir_A
Explorer
Explorer

Thanks Mate its work!

0 Likes
Message 14 of 19

Anonymous
Not applicable

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.

 

0 Likes
Message 15 of 19

Yien_Chao
Advisor
Advisor

Jeremy is right! 

my bad, i thought it was straight with elementid or worsetId, but is not after all.

0 Likes
Message 16 of 19

Anonymous
Not applicable

thanks! It worked

0 Likes
Message 17 of 19

leslie_smith29WFP
Observer
Observer

For those wishing to delete ALL worksets...

Open the central project file as "detach from central"

Select the option to "Detach and discard worksets"

 

I wanted to create a template from a workshare file and was unable...but by detaching and creating the standalone file, I was then able to save as a template.

0 Likes
Message 18 of 19

TripleM-Dev.net
Advisor
Advisor

Hope the workshared file wasn't modelled in much...just saying.

0 Likes
Message 19 of 19

leslie_smith29WFP
Observer
Observer

No there isn't a model built...it is just a central file as a basis for starting new projects.

So the Revit file has all the company standards included with sheets, views, general notes etc. all set up.

We wanted our typical worksets and view templates applied.  Once I got I where I wanted...we needed a standalone file ) no worksets for small single user project.

So now we have both options.

 

I've been a long time Revit user and myself prefer to use a workset project most of the time...not everybody does.

0 Likes