コード例 #1
0
        private void IsolateElement(bool execute, Document doc)
        {
            try
            {
                UIDocument uidoc   = new UIDocument(doc);
                Element    element = m_doc.GetElement(new ElementId(currentElement.ElementId));

                if (null != element && null != activeView)
                {
                    if (activeView.IsInTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate))
                    {
                        using (Transaction trans = new Transaction(doc))
                        {
                            trans.Start("Reset View");
                            try
                            {
                                activeView.DisableTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate);
                                uidoc.RefreshActiveView();
                                trans.Commit();
                            }
                            catch
                            {
                                trans.RollBack();
                            }
                        }
                    }
                    if (execute)
                    {
                        using (Transaction trans = new Transaction(doc))
                        {
                            trans.Start("Isolate");
                            try
                            {
                                List <ElementId> elementIds = new List <ElementId>();
                                elementIds.Add(element.Id);
                                activeView.IsolateElementsTemporary(elementIds);
                                uidoc.RefreshActiveView();
                                trans.Commit();
                            }
                            catch { trans.RollBack(); }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to highlight elements.\n" + ex.Message, "Highlight Elements", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bcfView"></param>
        /// <param name="removeHighlight"></param>
        /// <param name="removeIsolate"></param>
        /// <param name="removeSectionBox"></param>
        private void CleanViewSettings(View3D bcfView, bool removeHighlight, bool removeIsolate, bool removeSectionBox)
        {
            using (var trans = new Transaction(ActiveDoc))
            {
                trans.Start("Clean Views");
                try
                {
                    var uidoc = new UIDocument(ActiveDoc);
                    if (removeHighlight)
                    {
                        //remove selection
                        uidoc.Selection.SetElementIds(new List <ElementId>());
                    }

                    if (removeIsolate)
                    {
                        //remove isolation
                        if (bcfView.IsInTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate))
                        {
                            bcfView.DisableTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate);
                        }
                    }

                    if (removeSectionBox)
                    {
                        //remove sectionbox
                        bcfView.GetSectionBox().Enabled = false;
                    }

                    trans.Commit();
                }
                catch (Exception)
                {
                    trans.RollBack();
                }
            }
        }