public static RevitTooltip GetTooltipInfo(ProjectInfo projectInfo) { RevitTooltip settings = Revit.Addin.RevitTooltip.RevitTooltip.Default; if (projectInfo == null) { return(settings); } Schema tooltipSchema = Schema.Lookup(TooltipSchemaWrapper.SchemaGuid); if (tooltipSchema == null) { return(settings); } Entity tooltipEntity = projectInfo.GetEntity(tooltipSchema); if (tooltipEntity.Schema == null) { return(settings); } settings.DfServer = tooltipEntity.Get <string>("DfServer"); settings.DfDB = tooltipEntity.Get <string>("DfDB"); settings.DfPort = tooltipEntity.Get <string>("DfPort"); settings.DfUser = tooltipEntity.Get <string>("DfUser"); settings.DfPassword = tooltipEntity.Get <string>("DfPassword"); settings.DfCharset = tooltipEntity.Get <string>("DfCharset"); settings.SqliteFilePath = tooltipEntity.Get <string>("SqliteFilePath"); settings.SqliteFileName = tooltipEntity.Get <string>("SqliteFileName"); return(settings); }
private void DocumentClosingAction(object sender, DocumentClosingEventArgs even) { isThresholdChanged = true; color_blue = null; color_gray = null; color_red = null; settings = null; keyNameToElementMap = null; current_doc = null; m_uiApp.Idling -= SettingIdlingHandler; m_uiApp.Idling -= IdlingHandler; m_uiApp.Idling -= ImageControlIdlingHandler; if (even.Document.IsModified) { even.Document.Save(); } //关闭设置框 if (this.SettingsForm != null && !this.SettingsForm.IsDisposed) { this.SettingsForm.Dispose(); this.SettingsForm = null; } if (this.FatherImageForm != null && !this.FatherImageForm.IsDisposed) { this.FatherImageForm.Child.Dispose(); this.FatherImageForm.Dispose(); this.FatherImageForm = null; } }
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; } } }
public static void StoreTooltipInfo(ProjectInfo projectInfo, RevitTooltip settings) { using (Transaction createSchemaAndStoreData = new Transaction(projectInfo.Document, "tCreateAndStore")) { createSchemaAndStoreData.Start(); TooltipSchemaWrapper wrapper = new TooltipSchemaWrapper(settings); Schema tooltipSchema = wrapper.GetTooltipSchema(); Entity entity = new Entity(tooltipSchema); foreach (SettingsPropertyValue propertyValue in settings.PropertyValues) { Field field = tooltipSchema.GetField(propertyValue.Name); entity.Set <string>(field, propertyValue.PropertyValue.ToString()); } projectInfo.SetEntity(entity); createSchemaAndStoreData.Commit(); } }
public TooltipSchemaWrapper(RevitTooltip settings) { m_settings = settings; }