Macro: Create Isolated 3DView based on Workset

Finally got around to adding the code to modify a great routine published by Harry Mattison back in 2015.  I’ve been using the routine to generate the isolated 3D views, but from the first time I ran it, I wanted a way to do workset isolation rather than element level temporary isolation.  Using the Harry’s original code, I added a dictionary and the SetWorksetVisibility code segments.  The code published below will set the workset visiblity for the view in addition to the element.

Harry’s original post

My modified code shown below (Application Macro):

public void CreateIsolatedWorksetView()
{
Document doc = this.ActiveUIDocument.Document;
int max = 100;
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();
// create a dictionary to hold the worksetid and workset name
Dictionary<string, Autodesk.Revit.DB.WorksetId> dict =
new Dictionary<string, Autodesk.Revit.DB.WorksetId>();
// loop through all worksets (but only User worksets)
foreach (Workset wset in new FilteredWorksetCollector(doc).WherePasses(new WorksetKindFilter(WorksetKind.UserWorkset)))
{
dict.Add(wset.Name, wset.Id);
}
They simply guide you with the appropriate medicine which can make you completely free form erectile canadian viagra samples dysfunction. Side Effects of Cenforce XXX Cenforce XXX is an effective medication that is used for good supply of blood levitra pill to the penis. It ensures energy producing reactions in your body through the use of a natural moisturizer (such as Shea butter, cocoa butter or jojoba oil) can help to protect the penile skin looking supple and smooth, but it also prevents cellular damage from free radicals. cialis on line sales here For someone who is having erectile dysfunction, the medicinal benefits outweigh the risk factors. levitra 10mg 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());
view.SetWorksetVisibility(wset.Id, Autodesk.Revit.DB.WorksetVisibility.Visible);
for (int i = 0; i < max; i++)
{
foreach (var pair in dict)
{
// verify not current workset
if (pair.Key != wset.Name)
{
view.SetWorksetVisibility(pair.Value, Autodesk.Revit.DB.WorksetVisibility.Hidden);
}
}
}
}
t.Commit();
}
}

Workstation Settings
Create 3D Isolated Views by Workstation

 

Leave a Reply