Exemplo n.º 1
0
        private void refreshInterface()
        {
            try
            {
                //Fins material and set density
                CarboMaterial material = materials.GetExcactMatch(cbb_MixMaterial.Text);
                if (material != null && cbb_MixMaterial.Text != "")
                {
                    //Set the variables used later;
                    double densityToMix = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Density.Text);
                    double densityBase  = CarboLifeAPI.Utils.ConvertMeToDouble(txt_DensityBase.Text);

                    if (cbb_Unit.Text == "m³/m³" && densityToMix > 1)
                    {
                        txt_Density.Text = "1";
                    }

                    double result = 0;

                    if (material != null && densityBase >= 0)
                    {
                        result = calculateMixedMaterial(material, densityBase, densityToMix, cbb_Unit.Text);

                        txt_MixResult.Text = Math.Round(result, 3).ToString();

                        valueToBeMixed = result;
                        selectedMaterialDescription = material.Name + "(" + densityToMix + " " + cbb_Unit.Text + ")";
                    }
                }
            }
            catch
            {
//
            }
        }
Exemplo n.º 2
0
        public static DataTable ToDataTables(CarboMaterial material)
        {
            DataTable table = new DataTable();

            PropertyInfo[] propertyValues = typeof(CarboMaterial).GetProperties();

            table.Columns.Add("Property");
            table.Columns.Add("Value");

            for (int i = 0; i < propertyValues.Length; i++)
            {
                PropertyInfo property = propertyValues[i];

                if (property.PropertyType != typeof(A1A3Element))
                {
                    table.Rows.Add(property.Name, property.GetValue(material));
                }
            }

            /*
             * if (material.Properties.Count > 0)
             * {
             *  foreach (CarboProperty cp in material.Properties)
             *  {
             *      table.Rows.Add(cp.PropertyName, cp.Value);
             *  }
             * }
             */
            return(table);
        }
Exemplo n.º 3
0
        public MaterialEditor(string materialName, CarboDatabase database)
        {
            //originalMaterial = material;
            //selectedMaterial = material;
            try
            {
                //originalDatabase = database;
                returnedDatabase = database;
                selectedMaterial = database.GetExcactMatch(materialName);
                if (selectedMaterial == null)
                {
                    MessageBox.Show("This material could not be found in the database, the closest match will now be found");
                    selectedMaterial = database.getClosestMatch(materialName);
                }

                baseMaterials = new CarboDatabase();
                baseMaterials = baseMaterials.DeSerializeXML("db\\BaseMaterials");

                acceptNew = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            InitializeComponent();
        }
Exemplo n.º 4
0
        private void refreshInterface()
        {
            double volume    = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Volume.Text);
            double thickness = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Thickness.Text);

            if (cbb_ProfileMaterial != null && cbb_Profile != null)
            {
                CarboMaterial material        = materials.GetExcactMatch(cbb_ProfileMaterial.Text);
                Profile       selectedProfile = profileList.Find(x => x.name.Contains(cbb_Profile.Text));


                if (material != null && txt_Volume.Text != "" && thickness != 0 && selectedProfile != null)
                {
                    //=J13+((D13-K13)/1000)
                    //=Constsnt+((Thickness-ProfileHeight)/1000)
                    double area          = volume / (thickness / 1000);
                    double constant      = selectedProfile.constant;
                    double profileHeight = selectedProfile.profileHeight;

                    double conVolPerM2    = constant + ((thickness - profileHeight) / 1000);
                    double stlWeightPerM2 = selectedProfile.steel * 7850;


                    lbl_CalcCon.Content   = conVolPerM2 + " m³/m² x " + area + " m²";
                    lbl_CalcSteel.Content = Math.Round(stlWeightPerM2, 2) + " kg/m² x " + area + " m²";

                    txt_ConcreteVolume.Text = Convert.ToString(Math.Round((conVolPerM2 * area), 2));
                    txt_SteelVolume.Text    = Convert.ToString(Math.Round(((stlWeightPerM2 * area) / 7850), 2));
                }
            }
        }
Exemplo n.º 5
0
        public MaterialEndofLifePicker(CarboMaterial material)
        {
            carboMaterial = material;
            eolProperties = material.materialC1C4Properties;
            noUpdates     = true;

            InitializeComponent();
        }
        public MaterialBasePicker(CarboDatabase baseMaterials, string selection = "")
        {
            basematerials = baseMaterials;
            isAccepted    = false;

            selectedBaseMaterial = basematerials.GetExcactMatch(selection);

            InitializeComponent();
        }
        public MaterialBasePicker(string selection = "")
        {
            isAccepted    = false;
            basematerials = new CarboDatabase();

            basematerials        = basematerials.DeSerializeXML("");
            selectedBaseMaterial = basematerials.GetExcactMatch(selection);

            InitializeComponent();
        }
        private void lib_Materials_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            CarboMaterial cm = lib_Materials.SelectedItem as CarboMaterial;

            if (cm != null)
            {
                txt_Search.Text = cm.Name;
                refreshInterface();
            }
        }
        private void Txt_Search_TextChanged(object sender, TextChangedEventArgs e)
        {
            CarboMaterial material = basematerials.getClosestMatch(txt_Search.Text);

            selectedBaseMaterial = material;
            cbb_Categories.Text  = selectedBaseMaterial.Category;
            //lib_Materials.SelectedItem = selectedBaseMaterial;

            //refreshInterface();
        }
Exemplo n.º 10
0
        private void Liv_materialList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            selectedMaterial = liv_materialList.SelectedItem as CarboMaterial;
            //MaterialMap selectedFloorMap = GetMaterialMap(cbb_FloorTypes.Text);

            if (selectedMaterial != null)
            {
                UpdateSelectedMaterial();
            }
        }
Exemplo n.º 11
0
 public MaterialTransportPicker(CarboA4Properties c2Properties, CarboMaterial materialToBeTransported)
 {
     this.a4Properties = c2Properties;
     if (c2Properties.materialDensity != materialToBeTransported.Density)
     {
         MessageBoxResult dialogResult = MessageBox.Show("The transportation density does not match the meterial density, would you like to use: " + materialToBeTransported.Density + " kg/m³ as  a transportation density value?", "Warning", MessageBoxButton.YesNo);
         if (dialogResult == MessageBoxResult.Yes)
         {
             this.a4Properties.materialDensity = materialToBeTransported.Density;
         }
     }
     InitializeComponent();
 }
Exemplo n.º 12
0
        private void refreshInterface()
        {
            CarboMaterial material = materials.GetExcactMatch(cbb_ReinforcementMaterial.Text);
            double        volume   = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Volume.Text);
            double        density  = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Density.Text);


            if (material != null && txt_Volume.Text != "" && txt_Density.Text != "")
            {
                reinforcementGroup   = calculateRebar(material, reinforcementGroup, volume, density);
                txt_VolumeRebar.Text = reinforcementGroup.Volume.ToString();
                txt_WeightRebar.Text = reinforcementGroup.Mass.ToString();
            }
        }
Exemplo n.º 13
0
        private void Btn_New_Click(object sender, RoutedEventArgs e)
        {
            ValueDialogBox vdb = new ValueDialogBox("New Material Name");

            vdb.ShowDialog();
            if (vdb.isAccepted == true)
            {
                CarboMaterial newMaterial = new CarboMaterial();
                newMaterial.Name = vdb.Value;
                returnedDatabase.AddMaterial(newMaterial);

                RefreshMaterialList();
                selectMaterial(vdb.Value);
            }
        }
Exemplo n.º 14
0
        private double calculateMixedMaterial(CarboMaterial material, double densityBase, double densityToMix)
        {
            double result = 0;

            try
            {
                result = (densityToMix * material.ECI) / densityBase;
            }
            catch
            {
                return(0);
            }

            return(result);
        }
Exemplo n.º 15
0
        private void Btn_Accept_Click(object sender, RoutedEventArgs e)
        {
            isAccepted = true;
            CarboMaterial material = materials.GetExcactMatch(cbb_ProfileMaterial.Text);

            //concreteGroup.Volume = Utils.ConvertMeToDouble(txt_ConcreteVolume.Text);
            concreteGroup.Correction   = "*" + Math.Round(convertionFact, 3).ToString();
            concreteGroup.Description += " - Corrected volume";

            profileGroup.Volume      = Utils.ConvertMeToDouble(txt_SteelVolume.Text);
            profileGroup.Description = cbb_Profile.Text;
            profileGroup.Material    = material;
            profileGroup.CalculateTotals();

            this.Close();
        }
Exemplo n.º 16
0
        private void btn_Duplicate_Click(object sender, RoutedEventArgs e)
        {
            if (selectedMaterial != null)
            {
                ValueDialogBox vdb = new ValueDialogBox("New Material Name");
                vdb.txt_Value.Focus();
                vdb.ShowDialog();

                if (vdb.isAccepted == true)
                {
                    CarboMaterial newMaterial = DeepCopy <CarboMaterial>(selectedMaterial);
                    newMaterial.Name = vdb.Value;
                    returnedDatabase.AddMaterial(newMaterial);

                    RefreshMaterialList();
                    selectMaterial(vdb.Value);
                }
            }
        }
Exemplo n.º 17
0
        private CarboGroup calculateRebar(CarboMaterial material, CarboGroup reinforcementGroup, double volume, double density)
        {
            double steelDensity = material.Density;
            double steelWeight  = volume * density;
            double steelVolume  = steelWeight / steelDensity;

            reinforcementGroup.Volume       = steelVolume;
            reinforcementGroup.Mass         = steelWeight;
            reinforcementGroup.SubCategory  = "";
            reinforcementGroup.Category     = "Reinforcement";
            reinforcementGroup.Material     = material;
            reinforcementGroup.MaterialName = material.Name;
            reinforcementGroup.Density      = material.Density;
            reinforcementGroup.ECI          = material.ECI;

            reinforcementGroup.Description = "Reinforcement of: " + volume + "m³ " + "/ With: " + density + " kg/m³ Reinforcement";

            return(reinforcementGroup);
        }
Exemplo n.º 18
0
        private void refreshInterface()
        {
            CarboMaterial material = materials.GetExcactMatch(cbb_ReinforcementMaterial.Text);
            double        volume   = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Volume.Text);
            double        density  = CarboLifeAPI.Utils.ConvertMeToDouble(txt_Density.Text);



            if (material != null && txt_Volume.Text != "" && txt_Density.Text != "")
            {
                reinforcementGroup = calculateRebar(material, reinforcementGroup, volume, density);

                addtionalValue        = calculateMixedMaterial(material, concreteGroup.Density, density);
                additionalDescription = reinforcementGroup.Description;

                txt_VolumeRebar.Text = reinforcementGroup.Volume.ToString();
                txt_WeightRebar.Text = reinforcementGroup.Mass.ToString();
                txt_MixResult.Text   = Math.Round(addtionalValue, 3).ToString();
            }
        }
Exemplo n.º 19
0
        private double calculateMixedMaterial(CarboMaterial material, double densityBase, double densityToMix, string unit)
        {
            double result = 0;

            try
            {
                if (unit == "m³/m³")
                {
                    result = (((densityToMix / 1) * material.ECI) * material.Density) / densityBase;
                }
                else //kg/m³
                {
                    result = (densityToMix * material.ECI) / densityBase;
                }
            }
            catch (Exception ex)
            {
                selectedMaterialDescription = ex.Message;
            }

            return(result);
        }
Exemplo n.º 20
0
        public MaterialSelector(string selectedMaterialName, CarboDatabase database)
        {
            isAccepted = false;

            try
            {
                //originalDatabase = database;
                materialDatabase = database;
                currentMaterial  = database.GetExcactMatch(selectedMaterialName);

                if (currentMaterial == null)
                {
                    MessageBox.Show("This material could not be found in the database, a closest match will now be found for comparison");
                    currentMaterial = database.getClosestMatch(selectedMaterialName);
                }
                selectedMaterial = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            InitializeComponent();
        }
        private void btn_SyncFrom_Click(object sender, RoutedEventArgs e)
        {
            if (liv_TemplateMaterials.SelectedItems.Count > 0)
            {
                try
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to update the project materials  with the selected materials from the template?" + Environment.NewLine +
                                                                             "Materials with excact same name will be overwritten, others will be added to the project", "Warning", MessageBoxButton.YesNo);

                    if (result == MessageBoxResult.Yes)
                    {
                        CarboDatabase buffer = new CarboDatabase();

                        foreach (object item in liv_TemplateMaterials.SelectedItems)
                        {
                            CarboMaterial cm = item as CarboMaterial;
                            if (cm != null)
                            {
                                buffer.AddMaterial(cm);
                            }
                        }
                        projectDatabase.SyncMaterials(buffer);
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Please select a material to syncronise", "Computer says no", MessageBoxButton.YesNo);
            }

            refreshTemplateMaterials();
            refreshProjectMaterials();
        }
        private void btn_Delete_Click(object sender, RoutedEventArgs e)
        {
            bool deletedSucces = false;
            int  count         = 0;

            if (liv_TemplateMaterials.SelectedItems.Count == 1)
            {
                try
                {
                    CarboMaterial cm = liv_TemplateMaterials.SelectedItems[0] as CarboMaterial;

                    if (cm != null)
                    {
                        deletedSucces = templateDatabase.deleteMaterial(cm.Name);

                        if (deletedSucces == true)
                        {
                            count++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.ToString());
                    deletedSucces = false;
                }
            }
            else
            {
                for (int i = liv_TemplateMaterials.SelectedItems.Count; i > 0; i--)
                {
                    try
                    {
                        CarboMaterial cm = liv_TemplateMaterials.SelectedItems[i - 1] as CarboMaterial;
                        deletedSucces = templateDatabase.deleteMaterial(cm.Name);

                        if (deletedSucces == true)
                        {
                            count++;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show(ex.ToString());
                        deletedSucces = false;
                    }
                }


                // MessageBoxResult result = System.Windows.MessageBox.Show("Please select one material to delete", "Computer says no", MessageBoxButton.YesNo);
            }
            if (count == 1)
            {
                System.Windows.MessageBox.Show(count + " element deleted.", "Success", MessageBoxButton.OK);
            }
            else if (count > 1)
            {
                System.Windows.MessageBox.Show(count + " elements deleted.", "Success", MessageBoxButton.OK);
            }
            else
            {
                System.Windows.MessageBox.Show(0 + "elements deleted.", "Not a success", MessageBoxButton.OK);
            }

            refreshTemplateMaterials();
            refreshProjectMaterials();
        }
Exemplo n.º 23
0
        private void btn_OpenMaterialEditor_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check if a group has been selected:
                CarboGroup PotentialSelectedCarboGroup = new CarboGroup();
                PotentialSelectedCarboGroup.MaterialName = "";

                if (dgv_Overview.SelectedItems.Count > 0)
                {
                    var selectedItems = dgv_Overview.SelectedItems;
                    IList <CarboGroup> selectedGroups = new List <CarboGroup>();

                    // ... Add all Names to a List.
                    foreach (var item in selectedItems)
                    {
                        CarboGroup cg = item as CarboGroup;
                        if (cg != null)
                        {
                            selectedGroups.Add(cg);
                        }
                    }

                    if (selectedGroups.Count > 0)
                    {
                        PotentialSelectedCarboGroup = selectedGroups[0];
                    }
                }

                if (CarboLifeProject.CarboDatabase.CarboMaterialList.Count > 0)
                {
                    CarboMaterial carbomat = CarboLifeProject.CarboDatabase.CarboMaterialList[0];

                    if (PotentialSelectedCarboGroup.MaterialName != "")
                    {
                        //A group with a valid material was selected
                        carbomat = PotentialSelectedCarboGroup.Material;
                    }

                    if (carbomat == null)
                    {
                        carbomat = new CarboMaterial();
                    }

                    MaterialEditor materialEditor = new MaterialEditor(carbomat.Name, CarboLifeProject.CarboDatabase);
                    materialEditor.ShowDialog();

                    if (materialEditor.acceptNew == true)
                    {
                        CarboLifeProject.CarboDatabase = materialEditor.returnedDatabase;

                        CarboLifeProject.UpdateAllMaterials();
                    }
                }
                else
                {
                    MessageBox.Show("There were no materials found in the project, please re-create your project");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            CarboLifeProject.CalculateProject();
            refreshData();
        }
Exemplo n.º 24
0
        private CarboDatabase tryParseData(DataTable dt)
        {
            CarboDatabase result = new CarboDatabase();

            //List<String> fieldNameList = new List<string>();
            List <CarboMaterial> resultList = new List <CarboMaterial>();

            //Reach row is one element
            //Loop through datatab;e

            //int newIdNr = 10000;
            //int columncount = 0;

            PropertyInfo[]      propertyValues   = typeof(CarboMaterial).GetProperties();
            List <PropertyInfo> fullPropertyList = propertyValues.ToList();
            int propertyValuesCount = propertyValues.Length;

            foreach (DataRow dr in dt.Rows)
            {
                CarboMaterial       newMaterial  = new CarboMaterial();
                List <PropertyInfo> propertyList = new List <PropertyInfo>();
                foreach (PropertyInfo prInf in fullPropertyList)
                {
                    propertyList.Add(prInf);
                }
                //Set Id;
                //newMaterial.Id = newIdNr;
                //columncount = 0;
                bool valueisParameter = false;;

                foreach (DataColumn dc in dt.Columns)
                {
                    string ccolumnName   = dc.ColumnName.ToString().Trim();
                    string messageString = "";

                    for (int i = 0; i < propertyList.Count; i++)
                    {
                        PropertyInfo property     = propertyList[i];
                        string       propertyName = property.Name.ToString();

                        if (propertyName == ccolumnName)
                        {
                            string value = dr[dc].ToString();

                            //The column is a propery value, thus it need to be added as such
                            try
                            {
                                //Improved:

                                if (property.PropertyType == typeof(bool))
                                {
                                    int  parcedIntValue;
                                    bool isInt = false;

                                    isInt = int.TryParse(value, out parcedIntValue);

                                    if (isInt == false)
                                    {
                                        parcedIntValue = 0;
                                    }

                                    bool boolValue = Convert.ToBoolean(Convert.ToInt32(parcedIntValue));
                                    property.SetValue(newMaterial, boolValue);
                                }
                                else if (property.PropertyType == typeof(int))
                                {
                                    int  parcedIntValue;
                                    bool isInt = false;

                                    isInt = int.TryParse(value, out parcedIntValue);

                                    if (isInt == false)
                                    {
                                        parcedIntValue = 0;
                                    }

                                    //must be int
                                    property.SetValue(newMaterial, parcedIntValue);
                                }
                                else if (property.PropertyType == typeof(double))
                                {
                                    double parsedDoubleValue = 0;
                                    bool   isDouble          = false;

                                    isDouble = double.TryParse(value, out parsedDoubleValue);

                                    if (isDouble == false)
                                    {
                                        parsedDoubleValue = 0;
                                    }

                                    property.SetValue(newMaterial, parsedDoubleValue);
                                }
                                else if (property.PropertyType == typeof(string))
                                {
                                    if (value == null)
                                    {
                                        value = "";
                                    }

                                    property.SetValue(newMaterial, value);
                                }
                                else
                                {
                                    //Skip
                                }

                                //OLD

                                /*
                                 * if (isDouble == true)
                                 * {
                                 *  //Handle as number or bolean
                                 *
                                 *  if (property.PropertyType == typeof(bool))
                                 *  {
                                 *      bool boolValue = Convert.ToBoolean(Convert.ToInt32(value));
                                 *      property.SetValue(newMaterial, boolValue);
                                 *  }
                                 *  else
                                 *  {
                                 *      if (property.PropertyType == typeof(int))
                                 *      {
                                 *          //must be int
                                 *          property.SetValue(newMaterial, parcedIntValue);
                                 *      }
                                 *      else
                                 *      {
                                 *          //must be double
                                 *          //parsedDoubleValue = Math.Round(parsedDoubleValue, 2);
                                 *          property.SetValue(newMaterial, parsedDoubleValue);
                                 *      }
                                 *          //see if is int or double
                                 *  }
                                 * }
                                 * else
                                 * {
                                 *  //is string
                                 *  property.SetValue(newMaterial, value);
                                 * }
                                 */


                                //Value Successfully added
                                valueisParameter = false;

                                //removethePropertyFromlistToSpeedThingsUpNextRound;
                                propertyList.Remove(property);

                                //End the loop and go to next column
                                break;
                            }
                            catch (Exception ex)
                            {
                                messageString += value + " : " + ex.Message;
                            }
                        }
                        else
                        {
                            valueisParameter = true;
                        }
                    }

                    if (valueisParameter == true)
                    {
                        // If its not a property it will be added as a free parameter.

                        /*
                         * try
                         * {
                         *
                         *  CarboProperty newProperty = new CarboProperty();
                         *
                         *  string propertyValue = dr[dc].ToString();
                         *  string propertyName = ccolumnName;
                         *
                         *  newProperty.PropertyName = propertyName;
                         *  newProperty.Value = propertyValue;
                         *
                         *  if (ccolumnName.StartsWith("_"))
                         *  {
                         *      //This is a material
                         *      newProperty.PropertyName = propertyName.TrimStart('_');
                         *      newMaterial.Properties.Add(newProperty);
                         *  }
                         *  else
                         *  {
                         *      //This is a property
                         *      newMaterial.Properties.Add(newProperty);
                         *  }
                         * }
                         * catch (Exception ex)
                         * {
                         *  messageString += ex.Message;
                         * }
                         */
                    }

                    //columncount++;
                }
                newMaterial.CalculateTotals();
                resultList.Add(newMaterial);
                //lbl_Status.Text = newOption.Name;

                //lbl_Status.Refresh();
                //this.Refresh();
                //Next Id Nr:
                //newIdNr++;
            }
            //result.Floortype = -1;
            //result.FloorTypeName = txt_TypeName.Text;
            //result.FloorTypeDescription = txt_Description.Text;
            result.setData(resultList);
            return(result);
        }
Exemplo n.º 25
0
        public static CarboElement getNewCarboElement(Document doc, Element el, ElementId materialIds, CarboRevitImportSettings settings)
        {
            CarboElement newCarboElement = new CarboElement();

            try
            {
                int    setId;
                string setName;
                string setMaterialName;
                string setCategory;
                string setSubCategory;
                double setVolume;
                double setLevel;
                bool   setIsDemolished;
                bool   setIsSubstructure;
                bool   setIsExisting;

                // Material material = doc.GetElement(materialIds) as Material;
                //Id:
                setId = el.Id.IntegerValue;

                //Name (Type)
                ElementId   elId = el.GetTypeId();
                ElementType type = doc.GetElement(elId) as ElementType;
                setName = type.Name;

                //MaterialName
                setMaterialName = doc.GetElement(materialIds).Name.ToString();
                CarboMaterial carboMaterial = new CarboMaterial(setMaterialName);



                //GetDensity
                Parameter paramMaterial = el.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM);
                if (paramMaterial != null)
                {
                    Material material = doc.GetElement(paramMaterial.AsElementId()) as Material;
                    if (material != null)
                    {
                        PropertySetElement property = doc.GetElement(material.StructuralAssetId) as PropertySetElement;
                        if (property != null)
                        {
                            Parameter paramDensity = property.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_STRUCTURAL_DENSITY);
                            if (paramDensity != null)
                            {
                                double density = paramDensity.AsDouble();
                                carboMaterial.Density = density;
                            }
                        }
                    }
                }


                //Category
                setCategory = getValueFromList(el, type, settings.MainCategory, doc);

                //SubCategory
                setSubCategory = getValueFromList(el, type, settings.SubCategory, doc);

                //Volume

                double volumeCubicFt = el.GetMaterialVolume(materialIds);
                setVolume = Utils.convertToCubicMtrs(volumeCubicFt);

                newCarboElement.isDemolished = false;

                Level lvl = doc.GetElement(el.LevelId) as Level;
                if (lvl != null)
                {
                    setLevel = Convert.ToDouble((lvl.Elevation) * 304.8);
                }
                else
                {
                    setLevel = 0;
                }

                if (setLevel <= settings.CutoffLevelValue)
                {
                    setIsSubstructure = true;
                }
                else
                {
                    setIsSubstructure = false;
                }

                //Get Phasing;
                Phase elCreatedPhase = doc.GetElement(el.CreatedPhaseId) as Phase;
                Phase elDemoPhase    = doc.GetElement(el.DemolishedPhaseId) as Phase;


                if (elDemoPhase != null)
                {
                    setIsDemolished = true;
                }
                else
                {
                    setIsDemolished = false;
                }

                if (elCreatedPhase.Name == "Existing")
                {
                    setIsExisting = true;
                }
                else
                {
                    setIsExisting = false;
                }

                //Makepass;

                //Is existing and retained
                if (setIsExisting == true && setIsDemolished == false)
                {
                    if (settings.IncludeExisting == false)
                    {
                        return(null);
                    }
                }

                //Is demolished
                if (setIsDemolished == true)
                {
                    if (settings.IncludeDemo == false)
                    {
                        return(null);
                    }
                }

                //If it passed it is either proposed, or demolished and retained.

                newCarboElement.Id             = setId;
                newCarboElement.Name           = setName;
                newCarboElement.MaterialName   = setMaterialName;
                newCarboElement.Category       = setCategory;
                newCarboElement.SubCategory    = setSubCategory;
                newCarboElement.Volume         = Math.Round(setVolume, 4);
                newCarboElement.Material       = carboMaterial;
                newCarboElement.Level          = Math.Round(setLevel, 3);
                newCarboElement.isDemolished   = setIsDemolished;
                newCarboElement.isExisting     = setIsExisting;
                newCarboElement.isSubstructure = setIsSubstructure;

                if (newCarboElement.Volume != 0)
                {
                    return(newCarboElement);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                //TaskDialog.Show("Error", ex.Message);
                return(null);
            }
        }