Example #1
0
 public static OverrideGraphicSettings GetTingledOverrideGraphicSettings(Document doc)
 {
     if (_TingledOverrideGraphicSettings == null)
     {
         _TingledOverrideGraphicSettings = Revit_Helper.GetOverrideGraphicSettings(new Autodesk.Revit.DB.Color(185, 185, 185), GetDefaultFillPatternId(doc), 80);
     }
     return(_TingledOverrideGraphicSettings);
 }
Example #2
0
        OverrideGraphicSettings GetOverrideGraphicSettings(Document doc)
        {
            var setting = Revit_Helper.GetOverrideGraphicSettings(new Color(Color.R, Color.G, Color.B), FillerId == -1 ? GetDefaultFillPatternId(doc) : new ElementId(FillerId), SurfaceTransparency);

            setting.SetHalftone(IsHalftone);
            return(setting);

            //var setting = new OverrideGraphicSettings();
            //setting.SetHalftone(IsHalftone);
            //setting.SetProjectionFillPatternVisible(IsSurfaceVisible);
            //setting.SetProjectionFillColor(new Color(Color.R, Color.G, Color.B));
            //if (FillerId == -1)
            //    setting.SetProjectionFillPatternId(GetDefaultFillPatternId(doc));
            //else
            //    setting.SetProjectionFillPatternId(new ElementId(FillerId));
            //setting.SetSurfaceTransparency(SurfaceTransparency);
            //return setting;
        }
Example #3
0
        private bool DetailWithView(Document doc, string transactionName, string cpSettingsString, View3D view, ShowDialogType dialogType, Func <List <ElementId> > GetElementIds)
        {
            bool isSuccess;

            ListForm.ShowDialogType = dialogType;
            string viewName = dialogType.GetViewName();

            isSuccess = DealWithTransaction(viewName, doc, transactionName, () =>
            {
                view = Revit_Document_Helper.GetElementByNameAs <View3D>(UI_Doc.Document, viewName);
                if (view == null)
                {
                    view = Revit_Document_Helper.Create3DView(doc, viewName);
                }
                ////渲染_所有 隐藏
                //IList<Element> allElements = GetAllElements(doc);
                //List<ElementId> elementIdsToHid = new List<ElementId>();
                //foreach (var element in allElements)
                //    if (element.CanBeHidden(view) && element.Id != view.Id)
                //        elementIdsToHid.Add(element.Id);
                //if (elementIdsToHid.Count > 0)
                //    view.HideElements(elementIdsToHid);
                ////渲染_测点 淡显,显示
                //var allNodesElementIds = Model.GetAllNodesElementIds(doc);
                //var defaultOverrideGraphicSettings = CPSettings.GetTingledOverrideGraphicSettings(doc);
                //if (allNodesElementIds.Count > 0)
                //    view.UnhideElements(allNodesElementIds);
                //foreach (var elementId in allNodesElementIds)
                //    view.SetElementOverrides(elementId, defaultOverrideGraphicSettings);
                //渲染_选中 选中颜色显示
                var cpSettings = new CPSettings(cpSettingsString);
                var overrideGraphicSettings = Revit_Helper.GetOverrideGraphicSettings(new Color(cpSettings.Color.R, cpSettings.Color.G, cpSettings.Color.B), new ElementId(cpSettings.FillerId), cpSettings.SurfaceTransparency);
                var selectedElementIds      = GetElementIds();
                foreach (var elementId in selectedElementIds)
                {
                    view.SetElementOverrides(elementId, overrideGraphicSettings);
                }
            });
            if (view != null)
            {
                UI_Doc.ActiveView = view;
            }
            return(isSuccess);
        }
Example #4
0
        /// <summary>
        /// 视图逻辑处理
        /// 支持(隐藏,淡显,红显)和(反隐藏,淡显,红显)
        /// </summary>
        /// <param name="showDialogType"></param>
        /// <param name="needHide"></param>
        /// <param name="getElementIds"></param>
        /// <returns></returns>
        private bool DetailWithView(ShowDialogType showDialogType, bool needHide, Func <Document, List <ElementId> > getElementIds)
        {
            ListForm.ShowDialogType = showDialogType;
            string viewName        = ListForm.ShowDialogType.GetViewName();
            var    doc             = UI_Doc.Document;
            View3D view            = null;
            var    transactionName = nameof(SubsidenceMonitor) + nameof(btn_ViewSelection_Click);
            bool   isSuccess       = DealWithTransaction(viewName, doc, transactionName, () =>
            {
                view = Revit_Document_Helper.GetElementByNameAs <View3D>(UI_Doc.Document, viewName);
                if (view == null)
                {
                    view = Revit_Document_Helper.Create3DView(doc, viewName);
                }
                if (needHide)
                {
                    //渲染_所有 隐藏
                    IList <Element> allElements      = GetAllElements(doc);
                    List <ElementId> elementIdsToHid = new List <ElementId>();
                    foreach (var element in allElements)
                    {
                        if (element.CanBeHidden(view) && element.Id != view.Id)
                        {
                            elementIdsToHid.Add(element.Id);
                        }
                    }
                    if (elementIdsToHid.Count > 0)
                    {
                        view.HideElements(elementIdsToHid);
                    }
                    //渲染_测点 淡显
                    var nodesElementIds = Model.GetAllNodesElementIdsByTNode(doc);
                    if (nodesElementIds.Count > 0)
                    {
                        view.UnhideElements(nodesElementIds);
                    }
                    var defaultOverrideGraphicSettings = CPSettings.GetTingledOverrideGraphicSettings(doc);
                    foreach (var elementId in nodesElementIds)
                    {
                        view.SetElementOverrides(elementId, defaultOverrideGraphicSettings);
                    }
                }
                else
                {
                    ////渲染_所有 反隐藏
                    //IList<Element> allElements = GetAllElements(doc);
                    //List<ElementId> elementIdsToHid = new List<ElementId>();
                    //foreach (var element in allElements)
                    //    if (element.CanBeHidden(view) && element.Id != view.Id)
                    //        elementIdsToHid.Add(element.Id);
                    //view.UnhideElements(elementIdsToHid);
                    //渲染_所有 淡显
                    var allElementIds = GetAllElements(doc);
                    var defaultOverrideGraphicSettings = CPSettings.GetTingledOverrideGraphicSettings(doc);
                    foreach (var elementId in allElementIds)
                    {
                        view.SetElementOverrides(elementId.Id, defaultOverrideGraphicSettings);
                    }
                }
                //渲染_选中 红显
                var overrideGraphicSettings = Revit_Helper.GetOverrideGraphicSettings(ColorForSelectedElements, CPSettings.GetDefaultFillPatternId(doc), 0);
                var selectedElementIds      = getElementIds(doc);
                foreach (var elementId in selectedElementIds)
                {
                    view.SetElementOverrides(elementId, overrideGraphicSettings);
                }
            });

            if (view != null)
            {
                UI_Doc.ActiveView = view;
            }
            return(isSuccess);
        }