private void buttonParametersSettings_Click(object sender, RoutedEventArgs e) { try { MassParameterWindow paramWindow = new MassParameterWindow(m_app, massConfig); if ((bool)paramWindow.ShowDialog()) { massConfig = paramWindow.MassConfig; if (massConfig.UpdateType == ParameterUpdateType.FromHostToMass) { expanderParameter.Header = "Linked Parameters - (Floors to Masses)"; } else if (massConfig.UpdateType == ParameterUpdateType.FromMassToHost) { expanderParameter.Header = "Linked Parameters - (Masses to Floors)"; } dataGridParameters.ItemsSource = null; dataGridParameters.ItemsSource = massConfig.MassParameters; } } catch (Exception ex) { MessageBox.Show("Failed to set linked parameters.\n" + ex.Message, "Linked Parameters", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void buttonParametersSettings_Click(object sender, RoutedEventArgs e) { try { var paramWindow = new MassParameterWindow(app, massConfig); if (!(bool)paramWindow.ShowDialog()) { return; } massConfig = paramWindow.MassConfig; if (massConfig.UpdateType == ParameterUpdateType.FromHostToMass) { expanderParameter.Header = "Linked Parameters - (Areas to Masses)"; } else if (massConfig.UpdateType == ParameterUpdateType.FromMassToHost) { expanderParameter.Header = "Linked Parameters - (Masses to Areas)"; } dataGridParameters.ItemsSource = null; dataGridParameters.ItemsSource = massConfig.MassParameters; } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); MessageBox.Show("Failed to set linked parameters.\n" + ex.Message, "Linked Parameters", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public static MassConfiguration GetMassConfiguration(Document doc, SourceType massSource) { MassConfiguration massConfig = new MassConfiguration(); try { if (null == m_schema) { m_schema = CreateSchema(); } if (null != m_schema) { IList <DataStorage> savedStorage = GetMassConfigurationStorage(doc, m_schema); if (savedStorage.Count > 0) { foreach (DataStorage storage in savedStorage) { Entity entity = storage.GetEntity(m_schema); string hostCategory = entity.Get <string>(m_schema.GetField(s_HostCategory)); if (hostCategory == massSource.ToString()) { massConfig.MassSourceType = massSource; massConfig.HostCategory = hostCategory; massConfig.MassCategory = entity.Get <string>(m_schema.GetField(s_MassCategory)); massConfig.UpdateType = (ParameterUpdateType)Enum.Parse(typeof(ParameterUpdateType), entity.Get <string>(m_schema.GetField(s_ParameterUpdateType))); massConfig.UserHeight = entity.Get <double>(m_schema.GetField(s_UserHeight), DisplayUnitType.DUT_DECIMAL_FEET); massConfig.SetDefaultHeight = entity.Get <bool>(m_schema.GetField(s_SetDefaultHeight)); List <ParameterMapInfo> massParameters = new List <ParameterMapInfo>(); IList <Entity> subEntities = entity.Get <IList <Entity> >(m_schema.GetField(s_ParameterMaps)); foreach (Entity subE in subEntities) { string hostParamName = subE.Get <string>(subSchema.GetField(s_HostParameterName)); ParameterInfo hostParamInfo = GetParameterInfo(doc, massConfig.HostCategory, hostParamName); string massParamName = subE.Get <string>(subSchema.GetField(s_MassParameterName)); ParameterInfo massParamInfo = GetParameterInfo(doc, massConfig.MassCategory, massParamName); if (null != hostParamInfo && null != massParamInfo) { ParameterMapInfo mapInfo = new ParameterMapInfo(hostParamInfo, massParamInfo); massParameters.Add(mapInfo); } } massConfig.MassParameters = massParameters; break; } } } } } catch (Exception ex) { MessageBox.Show("Failed to get mass configuration.\n" + ex.Message, "Get Mass Configuration", MessageBoxButton.OK, MessageBoxImage.Warning); } return(massConfig); }
public AreaWindow(UIApplication uiapp, Dictionary <string, RevitDocumentProperties> models, Dictionary <string, AreaProperties> dictionary) { app = uiapp; doc = app.ActiveUIDocument.Document; modelDictionary = models; AreaDictionary = dictionary; InitializeComponent(); Title = "Create Mass v." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; var documents = modelDictionary.Values.OrderBy(o => o.DocumentTitle).ToList(); comboBoxModel.ItemsSource = documents; //area elements only in host doc var index = documents.FindIndex(o => o.IsLinked == false); if (index > -1) { comboBoxModel.SelectedIndex = index; } massConfig = MassConfigDataStorageUtil.GetMassConfiguration(doc, SourceType.Areas); massConfig.MassSourceType = SourceType.Areas; massConfig.HostCategory = "Areas"; massConfig.MassCategory = "Mass"; if (massConfig.UpdateType == ParameterUpdateType.FromHostToMass) { expanderParameter.Header = "Linked Parameters - (Areas to Masses)"; } else if (massConfig.UpdateType == ParameterUpdateType.FromMassToHost) { expanderParameter.Header = "Linked Parameters - (Masses to Areas)"; } dataGridParameters.ItemsSource = null; dataGridParameters.ItemsSource = massConfig.MassParameters; }
public MassParameterWindow(UIApplication uiapp, MassConfiguration configuration) { m_app = uiapp; m_doc = m_app.ActiveUIDocument.Document; massConfig = configuration; mapInfoList = massConfig.MassParameters; GetParameterInformation(); InitializeComponent(); labelHostCategoryName.Content = configuration.HostCategory; labelMassCategoryName.Content = configuration.MassCategory; DisplayParameterMapInfo(); DisplayParameterInfo(); if (massConfig.UpdateType == ParameterUpdateType.FromHostToMass) { radioButtonHostToMass.IsChecked = true; } else if (massConfig.UpdateType == ParameterUpdateType.FromMassToHost) { radioButtonMassToHost.IsChecked = true; } }
public static bool StoreMassConfiguration(Document doc, MassConfiguration mc) { bool stored = false; try { if (null == m_schema) { m_schema = CreateSchema(); } if (null != m_schema) { IList <DataStorage> savedStorage = GetMassConfigurationStorage(doc, m_schema); if (savedStorage.Count > 0) { using (Transaction trans = new Transaction(doc)) { trans.Start("Delete Storage"); try { foreach (DataStorage storage in savedStorage) { Entity entity = storage.GetEntity(m_schema); string hostCategory = entity.Get <string>(m_schema.GetField(s_HostCategory)); if (hostCategory == mc.HostCategory) { doc.Delete(storage.Id); break; } } trans.Commit(); } catch (Exception ex) { trans.RollBack(); MessageBox.Show("Failed to delete data storage for mapping items.\n" + ex.Message, "Delete Data Storage", MessageBoxButton.OK, MessageBoxImage.Warning); } } } using (Transaction trans = new Transaction(doc)) { trans.Start("Save Storage"); try { DataStorage storage = DataStorage.Create(doc); Entity entity = new Entity(schemaId); entity.Set <string>(s_HostCategory, mc.HostCategory); entity.Set <string>(s_MassCategory, mc.MassCategory); entity.Set <string>(s_ParameterUpdateType, mc.UpdateType.ToString()); entity.Set <bool>(s_SetDefaultHeight, mc.SetDefaultHeight); entity.Set <double>(s_UserHeight, mc.UserHeight, DisplayUnitType.DUT_DECIMAL_FEET); List <Entity> subEntities = new List <Entity>(); foreach (ParameterMapInfo paramMapInfo in mc.MassParameters) { Entity subEntity = new Entity(subSchemaId); subEntity.Set <string>(s_HostParameterName, paramMapInfo.HostParamInfo.ParameterName); subEntity.Set <string>(s_MassParameterName, paramMapInfo.MassParamInfo.ParameterName); subEntities.Add(subEntity); } entity.Set <IList <Entity> >(s_ParameterMaps, subEntities); storage.SetEntity(entity); trans.Commit(); stored = true; } catch (Exception ex) { trans.RollBack(); MessageBox.Show("Failed to save mapping items.\n" + ex.Message, "Store Mapping Information", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } catch (Exception ex) { MessageBox.Show("Failed to store mass configuration.\n" + ex.Message, "Store Mass Configuration", MessageBoxButton.OK, MessageBoxImage.Warning); } return(stored); }