/// <summary> /// Update all the groups with the current materials in the database. /// </summary> public void UpdateAllMaterials() { List <string> updatedmaterials = new List <string>(); foreach (CarboGroup gr in this.groupList) { try { CarboMaterial cm = CarboDatabase.GetExcactMatch(gr.Material.Name); if (cm != null) { if (cm.ECI != gr.ECI) { //The material has been changed, update required. gr.Material = cm; if (gr.AllElements.Count > 0) { gr.RefreshValuesFromElements(); } gr.CalculateTotals(); updatedmaterials.Add(gr.MaterialName); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// After creating a mapping list, you can use this method to update all map all the groups in a project. /// </summary> public void mapAllMaterials() { if (carboMaterialMap != null) { if (carboMaterialMap.Count > 0) { foreach (CarboGroup gr in this.groupList) { try { //MApping only works where elements are imported from Revit and the group contains elements if (gr.AllElements != null && gr.AllElements.Count > 0) { //First see if a change is required; //Find the map file of this group using a single element in the group; CarboMapElement mapElement = GetMapItem(gr.AllElements[0].MaterialName, gr.Category); if (mapElement != null) { //Get the material from the mapping name; CarboMaterial cm = CarboDatabase.GetExcactMatch(mapElement.carboNAME); if (cm != null) { //see if the material need changing; if (cm.Name != gr.MaterialName) { //Only update if the mapping file suggest a change. gr.Material = cm; gr.RefreshValuesFromElements(); gr.CalculateTotals(); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } else { MessageBox.Show("Please setup your material map first."); } }
public void UpdateAllMaterials() { List <string> updatedmaterials = new List <string>(); foreach (CarboGroup gr in this.groupList) { CarboMaterial cm = CarboDatabase.GetExcactMatch(gr.Material.Name); if (cm != null) { if (cm.ECI != gr.ECI) { //The material has been changed, update required. gr.Material = cm; gr.RefreshValuesFromElements(); gr.CalculateTotals(); updatedmaterials.Add(gr.MaterialName); } } } }