Hi,
Im trying to open a closed workset in an already opened document.
Can this be done?
The IsOpen property is readonly.
I know I can open set the worksets to open when I open the document, but what about an allready open document?
Thanks
Erik
Hi Erik,
Good question, but now I have one for you, Can you do this from the Revit UI ? Same workflow you want to do from the API.
If you can, I will ask about it, but in case you cannot, most likely you will not be able from the API as well.
Revit API most of the time can do almost everything you can from the Revit UI.
Cheers,
Hi Jaime,
No problem, just go to the worksets dialog (collaboration->manage collaboration -> worksets)
and select the workset you want to open and press open.
I know, and since 2015 R2 I thought we could do it all with worksets, but I cant seem to find this.
Please see attached file for the workset dialog.
Thanks
Erik
Hi Erik,
I have asked our Revit engineers for some information about if this is possible. I will get back to you once I hear from them.
Thank you for your patience.
Cheers,
Hi Erik,
Sorry for the long wait, The Revit engineers have confirmed that such functionality it is not possible at the moment from the API. I have filled a wish request on your behalf. Please feel free to check in the future about status on this request. Thank you once again for your collaboration and patience.
Cheers,
Dear Jamie,
I have faced the same problem recently.
Is there any news about this API functionality?
I would like a solution for this as well. This would be very helpful for batch opening files.
Regards
Hi, I have found workaround for opening worksets when document is already opened. Did you know that if you in schedule try to "Highlight in Model" element that is in closed workset, Revit will automaticaly open that workset, without notifying user. So if you create new element (In example below Cable Tray) and move it to closed workset that you want to open and call "uidoc.ShowElements(ids);" on that element, revit will open that workset and you can delete cable tray after. Please note that if there is no good open view "showElements" metod will promp user and ask if it can search other view... I could not supress this popup with "WarningSwallower" so I end up creating new 3D view, and activating it to go over this.
The solution is a bit ugly but it is working.
using (TransactionGroup tGroup = new TransactionGroup(doc))
{
using (Transaction t = new Transaction(doc))
{
tGroup.Start("Open All Worksets");
//list of all worksets
FilteredWorksetCollector collectorWorksett = new FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset);
foreach (Workset w in collectorWorksett.ToWorksets())
{
if (!w.IsOpen)
{
t.Start("Open workset");//Crating temporary cable tray
ElementId typeID = new FilteredElementCollector(doc).WhereElementIsElementType().OfClass(typeof(CableTrayType)).ToElementIds().First();
ElementId levelID = new FilteredElementCollector(doc).OfClass(typeof(Level)).ToElementIds().First();
CableTray ct = CableTray.Create(doc, typeID, new XYZ(0, 0, 0), new XYZ(0, 0, 1), levelID);
ElementId elementId = ct.Id;
//Changing workset of cable tray to workset which we want to open
Parameter wsparam = ct.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM);
if (wsparam != null && !wsparam.IsReadOnly) wsparam.Set(w.Id.IntegerValue);
List<ElementId> ids = new List<ElementId>();
ids.Add(elementId);
//This command will actualy open workset
uidoc.ShowElements(ids);
//Delete temporary cable tray
doc.Delete(elementId);
t.Commit();
}
}
tGroup.Assimilate();
}// End - Transaction
}// END - Transaction group
Kind Regards,
Filip Nekic
BIM Consultant
https://bimclinic.com/
Thank you for your work!
Colleagues, you may be able to suggest: I open several models with the command
new_doc = app.OpenDocumentFile(path, open_options)
- to select elements in a new model, i need to select the UI for it.
uidoc.ShowElements(ids) refers to the model from which the dynamo was launched.
Is it possible to choose a UI in an open model?
Thanks for your attention.