Macro function to Isolate selected assembly instances. After the isolation view is empty.
public void IsolateAssembly()
{
UIDocument uiDoc = ActiveUIDocument;
Document doc = uiDoc.Document;
List<ElementId> elements = new List<ElementId>();
foreach (var id in uiDoc.Selection.GetElementIds())
{
Element tempElem = doc.GetElement(id);
if(tempElem is AssemblyInstance)
{
elements.Add(tempElem.Id);
}
}
using (Transaction tx = new Transaction(doc))
{
tx.Start("Isolate Assembly");
doc.ActiveView.IsolateElementsTemporary(elements);
uiDoc.RefreshActiveView();
tx.Commit();
}
}
Assembly instance is just the container so you need to get the members via AssemblyInstance.GetMemberIds and isolate those with the assembly instance.
AssemblyInstance El = Doc.GetElement(R) as AssemblyInstance;
ICollection<ElementId> EIDs = El.GetMemberIds();
EIDs.Add(El.Id);
using (Transaction Tx = new Transaction(Doc, "Temp isolate"))
{
if (Tx.Start() == TransactionStatus.Started)
{
UIDoc.ActiveGraphicalView.IsolateElementsTemporary(EIDs);
Tx.Commit();
}
}
If I isolate assembly through Revit
If I isolate through collecting member ids the result is not the same. I need to isolate assembly instances like Revit not the members of assembly instances.
Isolating elements in view and what is contained in the current selection are two different things. So after isolating all of the objects try setting the current selection to the assembly instance only.
UIDocument.Selection.SetElementIds()
Can't find what you're looking for? Ask the community or share your knowledge.