Create a 3d view for each workset, and in that view isolate the display of the elements in that workset.
Note that to find worksets we use a FilteredWorksetCollector (not a FilteredElementCollector) and a WorksetKindFilter to get only the user worksets (don’t want view, family, project standard worksets).
public void ViewWorksetIso()
{
Document doc = this.ActiveUIDocument.Document;
if (!doc.IsWorkshared)
return;
// get the 3d view type which is needed when creating 3d views
ViewFamilyType vft = new FilteredElementCollector(doc)
.OfClass(typeof(ViewFamilyType))
.Cast<ViewFamilyType>()
.FirstOrDefault(q => q.ViewFamily == ViewFamily.ThreeDimensional);
using (Transaction t = new Transaction(doc, "workset view isolation"))
{
t.Start();
// loop through all worksets (but only User worksets)
foreach (Workset wset in new FilteredWorksetCollector(doc).WherePasses(new WorksetKindFilter(WorksetKind.UserWorkset)))
{
// create a 3d view
View3D view = View3D.CreateIsometric(doc, vft.Id);
// set the name of the view to match the name of the workset
view.Name = "WORKSET - " + wset.Name;
// isolate elements in the view, using a filter to find elements only in this workset
view.IsolateElementsTemporary(new FilteredElementCollector(doc).WherePasses(new ElementWorksetFilter(wset.Id)).Select(q => q.Id).ToList());
}
t.Commit();
}
}
Harry,
I appreciate the Granted Wishes, but I have a suggestion on #7.
Wouldn’t it make more sense to create a 3D view where all worksets, except for one, are turned off? I really like the concept of this macro, but when I select elements that should be on another workset, and assign them to the correct workset, they remain visible. At this point, I have to delete the views and re-run the macro.
Thanks, and keep up the good work!
Hi Sam – Yes, using the View.SetWorksetVisibility Method would be another way to do this
[…] #RTCNA Wish 7 granted! Isolated 3d view for each workset […]
[…] #RTCNA Wish 7 granted! Isolated 3d view for each workset […]
thanks so much for this. I had moved it over to my application and it was working but then had to rebuild my machine and now I’ve lost it. I keep getting an error when I build it
} expected (CS1513) – C:\ProgramData\Autodesk\Revit\Macros\2015\Revit\AppHookup\RTC\Source\RTC\ThisApplication.cs:69,2
Have you checked that you have the same # of open and close curly brackets? { and }
Yes that seems to be what the error suggests but I’m vutting and pasting from your page. And I’m essentially copying from “Public void..” down and pasting it in place.
[…] Harry’s original post […]
An oldie but a goodie, thanks Harry. I’ve been using this one for a while now.
Sam, I added the code to set workset visibility in my latest blog post at besidethecursor.
http://www.integr-8.com/macro-create-isolated-3dview-based-on-workset/