Beispiel #1
0
        private void DocumentOpenedAction(object sender, DocumentOpenedEventArgs even)
        {
            settings              = ExtensibleStorage.GetTooltipInfo(even.Document.ProjectInformation);
            this.mysql            = new MysqlUtil(settings);
            this.sqlite           = new SQLiteHelper(settings);
            m_previousDocPathName = even.Document.PathName;
            current_doc           = even.Document;

            //过滤测点待使用
            //打开文档就过滤一次
            keyNameToElementMap = new Dictionary <string, Element>();
            BuiltInParameter       testParam   = BuiltInParameter.ALL_MODEL_TYPE_NAME;
            ParameterValueProvider pvp         = new ParameterValueProvider(new ElementId(testParam));
            FilterStringEquals     eq          = new FilterStringEquals();
            FilterRule             rule        = new FilterStringRule(pvp, eq, Res.String_ParameterSurveyType, false);
            ElementParameterFilter paramFilter = new ElementParameterFilter(rule);
            Document document = current_doc;
            FilteredElementCollector elementCollector = new FilteredElementCollector(document).OfClass(typeof(FamilyInstance));
            IList <Element>          elems            = elementCollector.WherePasses(paramFilter).ToElements();

            foreach (var elem in elems)
            {
                string    param_value = string.Empty;
                Parameter param       = elem.get_Parameter(Res.String_ParameterName);
                if (null != param && param.StorageType == StorageType.String)
                {
                    param_value = param.AsString();
                    if (!string.IsNullOrWhiteSpace(param_value))
                    {
                        keyNameToElementMap.Add(param_value, elem);
                    }
                }
            }


            //准备Material
            IEnumerable <Material> allMaterial = new FilteredElementCollector(even.Document).OfClass(typeof(Material)).Cast <Material>();

            foreach (Material elem in allMaterial)
            {
                if (elem.Name.Equals(Res.String_Color_Redline))
                {
                    color_red = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Gray))
                {
                    color_gray = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Blue))
                {
                    color_blue = elem;
                }
                if (color_gray != null && color_red != null && color_blue != null)
                {
                    this.ColorMaterialIsReady = true;
                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// SettingForm的闲置事件处理函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void SettingIdlingHandler(
            object sender,
            IdlingEventArgs args)
        {
            UIApplication uiapp = sender as UIApplication;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            if (null != uidoc)
            {
                //把settings保存至模型
                if (isSettingChange)
                {
                    ExtensibleStorage.StoreTooltipInfo(CurrentDoc.ProjectInformation, settings);
                    App.Instance.CurrentDoc.Save();
                    isThresholdChanged = false;
                    isSettingChange    = false;
                }
            }
        }