- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to replicate Select by ID for Alignment elements. For example, I can get a constraint element Id using RevitLookup → GetDependentElements → Dimensions.
Then I can use Manage → Inquiry → Select by ID to find the constraining line. If only one ID is typed in, both the line and the constraint lock are displayed. Revit annoyingly makes the lock disappear if multiple IDs are entered, but that issue is for another day.
The important point here is the lock, which is usually only displayed when using the Align tool, and otherwise cannot easily be unlocked. Figuring out which elements have which constraints graphically is thus time-consuming and difficult to do. This is the frustration I am trying to circumvent.
I can select the offending locks with a macro, but it does not show the lock icons.
public void ShowAlignments()
{
UIApplication uiapp = new UIApplication(Application);
IList<ElementId> selectedIds = new List<ElementId>();
IList<Reference> selectedRefs = uiapp.ActiveUIDocument.Selection.PickObjects(ObjectType.Element, "Pick an element");
foreach (Reference r in selectedRefs)
{
selectedIds.Add(r.ElementId);
}
HashSet<ElementId> allAlignmentIds = new HashSet<ElementId>();
foreach (ElementId id in selectedIds)
{
var cst = BuiltInCategory.OST_Constraints;
var cef = new ElementCategoryFilter(cst);
allAlignmentIds.UnionWith(doc.GetElement(id).GetDependentElements(cef));
}
uiapp.ActiveUIDocument.Selection.SetElementIds(allAlignmentIds);
}
One more thing -- Reveal Constraints is unhelpful here. Using either Select by ID (UI) or SetElementIds (API) in that view mode, the display is no more helpful, and only turns some of the constraint lines blue to indicate selection. If the same line is used in another element constraint, it remains red even when selected. In the following example, the two blue vertical lines on the left and the two red horizontal lines are both selected.
How do I make the lock icon show up like it does using the Select by ID tool? Bonus points for showing multiple locks to identify each of the constraints.
Solved! Go to Solution.