Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to delete a workset?

15 REPLIES 15
Reply
Message 1 of 16
WhiteSharx
10499 Views, 15 Replies

How to delete a workset?

Hello everybody!

 

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

15 REPLIES 15
Message 2 of 16
devonpowell
in reply to: WhiteSharx

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.

Message 3 of 16
WhiteSharx
in reply to: devonpowell

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?

Message 4 of 16
devonpowell
in reply to: WhiteSharx

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 16
m.voss.alvine
in reply to: devonpowell

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 16
devonpowell
in reply to: WhiteSharx

This isn't the API forum, so he is asking if there is a programmatic way to delete a work set.
Message 7 of 16
devonpowell
in reply to: WhiteSharx

I meant it IS the API forum.
Message 8 of 16

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!

Tags (3)
Message 9 of 16

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

 

Tags (1)
Message 10 of 16

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

Message 11 of 16
jeremytammik
in reply to: WhiteSharx

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 16
Yien_Chao
in reply to: WhiteSharx

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

 

Message 13 of 16
Yanir_A
in reply to: bjones

Thanks Mate its work!

Message 14 of 16

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.

 

Message 15 of 16

Jeremy is right! 

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

Message 16 of 16
chandrima.s
in reply to: bjones

thanks! It worked

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community