Пример #1
0
        private void HighlightElement()
        {
            using (var trans = new Transaction(CurrentDocument))
            {
                trans.Start("Select Element");
                try
                {
                    var uidoc = new UIDocument(CurrentDocument);
#if RELEASE2014
                    Element element = m_doc.GetElement(selectedLinkedInfo.LinkedElementId);
                    if (null != element)
                    {
                        SelElementSet selElements = uidoc.Selection.Elements;
                        selElements.Insert(element);

                        uidoc.Selection.Elements = selElements;
                    }
#else
                    var selectedIds = new List <ElementId>
                    {
                        SelectedLinkedInfo.LinkedElementId
                    };
                    uidoc.Selection.SetElementIds(selectedIds);
#endif
                    uidoc.ShowElements(SelectedLinkedInfo.LinkedElementId);
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.RollBack();
                    MessageBox.Show("Failed to select an element.\n" + ex.Message, "Select Element", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }