Esempio n. 1
0
        public List<Assembly> RetrieveWallInfo()
        {
            List<Assembly> assemblies = new List<Assembly>();
            ICollection<Element> walls = getElementsOfCategory(doc, BuiltInCategory.OST_Walls, typeof(Wall));

            foreach (Element e in walls)
            {
                Wall w = null;
                WallType wType = null;
                w = (Wall)e;
                Assembly assem = new Assembly();
                wType = w.WallType;
                if (wType.Kind == WallKind.Basic)
                {
                    Parameter assemName = wType.get_Parameter("Assembly Description");
                    assem.AssemblyName = assemName.AsString();
                    Parameter assemCode = wType.get_Parameter("Assembly Code");
                    assem.AssemblyCode = assemCode.AsString();
                    assem.Category = AssemblyUtil.GetCategoryFromCode(assem.AssemblyCode);
                    //get all materials associated with this assembly
                    List<AssemMaterial> mats = new List<AssemMaterial>();

                    foreach (Material m in w.Materials)
                    {
                        // MessageBox.Show(String.Format("{0} : {1}: Area = {2}", assemName.AsString(), m.Name, w.GetMaterialArea(m)));
                        AssemMaterial mat = new AssemMaterial();
                        mat.Name = m.Name;
                        mats.Add(mat);
                    }
                    assem.Materials = mats;

                    //get area and volume for each assembly
                    foreach (Parameter p in w.Parameters)
                    {
                        if (p.Definition.Name.Equals("Area"))
                        {
                            if (p.HasValue)
                            {
                                assem.Area = p.AsDouble();
                            }
                        }
                        else if (p.Definition.Name.Equals("Volume"))
                        {
                            if (p.HasValue)
                            {
                                assem.Volume = p.AsDouble();
                            }
                        }
                    }
                    //if(!assemblies.Contains(assem))
                    assemblies.Add(assem);
                }
            }
            return assemblies;
        }
Esempio n. 2
0
        public List<Assembly> RetrieveRoofingInfo()
        {
            List<Assembly> assemblies = new List<Assembly>();
            ICollection<Element> roofing = getElementsOfCategory(doc, BuiltInCategory.OST_Roofs, typeof(RoofBase));

            foreach (Element e in roofing)
            {
                RoofBase roof = null;
                RoofType rType = null;
                roof = (RoofBase)e;
                Assembly assem = new Assembly();
                rType = roof.RoofType;

                Parameter assemName = rType.get_Parameter("Assembly Description");
                assem.AssemblyName = assemName.AsString();
                Parameter assemCode = rType.get_Parameter("Assembly Code");
                assem.AssemblyCode = assemCode.AsString();
                assem.Category = AssemblyUtil.GetCategoryFromCode(assem.AssemblyCode);
                //get all materials associated with this assembly
                List<AssemMaterial> mats = new List<AssemMaterial>();
                foreach (Material m in roof.Materials)
                {
                    AssemMaterial mat = new AssemMaterial();
                    mat.Name = m.Name;
                    mats.Add(mat);
                }
                assem.Materials = mats;

                //get area and volume for each assembly
                foreach (Parameter p in roof.Parameters)
                {
                    if (p.Definition.Name.Equals("Area"))
                    {
                        if (p.HasValue)
                        {
                            assem.Area = p.AsDouble();
                        }
                    }
                    else if (p.Definition.Name.Equals("Volume"))
                    {
                        if (p.HasValue)
                        {
                            assem.Volume = p.AsDouble();
                        }
                    }
                }
                //if(!assemblies.Contains(assem))
                assemblies.Add(assem);
            }
            return assemblies;
        }
Esempio n. 3
0
        public List<AssemMaterial> getMaterialsByAssemblyName(String assemName)
        {
            List<AssemMaterial> materials = new List<AssemMaterial>();
            using (OleDbConnection conn = this.getConnection())
            {
                conn.Open();
                using (OleDbCommand comm = conn.CreateCommand())
                {

                    comm.CommandType = CommandType.Text;
                    comm.CommandText = "SELECT MatName, Description, CostPerUnit, CO2PerUnit, Unit, LaborCost, LaborHours, DailyOutput " +
                                       "FROM Material INNER JOIN Labor ON (Material.ID = Labor.MaterialID)" +
                                       "WHERE Material.ID IN " +
                                       "(SELECT MaterialID FROM Assem_Mat WHERE AssemblyID = " +
                                       "(SELECT ID FROM Assembly WHERE AssemName =?)) ORDER BY MatName;";
                    comm.Parameters.AddWithValue("@name", assemName);
                    using (OleDbDataReader reader = comm.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            materials = new List<AssemMaterial>();
                            while (reader.Read())
                            {
                                AssemMaterial m = new AssemMaterial();
                                MaterialLabor labor = new MaterialLabor();
                                m.Name = reader["MatName"].ToString();
                                m.Description = reader["Description"].ToString();
                                m.CostPerUnit = (double)reader["CostPerUnit"];
                                m.CO2PerUnit = (double)reader["CO2PerUnit"];
                                m.Unit = reader["Unit"].ToString();
                                labor.Cost = (double)reader["LaborCost"];
                                labor.DailyOutPut = (double)reader["DailyOutput"];
                                labor.Hours = (double)reader["LaborHours"];
                                m.Labor = labor;
                                materials.Add(m);
                            }
                        }
                    }
                }
                conn.Close();
            }
            return materials;
        }
Esempio n. 4
0
        public List<Assembly> RetrieveFloorInfo()
        {
            List<Assembly> assemblies = new List<Assembly>();
            ICollection<Element> floors = getElementsOfCategory(doc, BuiltInCategory.OST_StructuralFoundation, typeof(Floor));

            foreach (Element e in floors)
            {
                Floor floor = null;
                FloorType fType = null;
                floor = (Floor)e;
                Assembly assem = new Assembly();
                fType = floor.FloorType;

                Parameter assemName = fType.get_Parameter("Assembly Description");

                assem.AssemblyName = floor.Name;
                //assem.AssemblyName = assemName.AsString();
                Parameter assemCode = fType.get_Parameter("Assembly Code");
                if (String.IsNullOrEmpty(assemCode.AsString()))
                    assem.AssemblyCode = "A1030";
                else
                    assem.AssemblyCode = assemCode.AsString();
                assem.Category = AssemblyUtil.GetCategoryFromCode(assem.AssemblyCode);
                //get all materials associated with this assembly
                List<AssemMaterial> mats = new List<AssemMaterial>();
                foreach (Material m in floor.Materials)
                {
                    AssemMaterial mat = new AssemMaterial();
                    mat.Name = m.Name;
                    mats.Add(mat);
                }
                assem.Materials = mats;

                //get area and volume for each assembly
                foreach (Parameter p in floor.Parameters)
                {
                    if (p.Definition.Name.Equals("Area"))
                    {
                        if (p.HasValue)
                        {
                            assem.Area = p.AsDouble();
                        }
                    }
                    else if (p.Definition.Name.Equals("Volume"))
                    {
                        if (p.HasValue)
                        {
                            assem.Volume = p.AsDouble();
                        }
                    }
                }
                //if(!assemblies.Contains(assem))
                assemblies.Add(assem);
            }
            return assemblies;
        }
Esempio n. 5
0
        public void CalculateWallAssemblies(Type ty)
        {
            double totalVolume = 0.0;
            double totalArea = 0.0;

            //hold total volume for each assembly code
            assemblyVolumes = new Dictionary<Assembly, double>();
            assemblyAreas = new Dictionary<Assembly, double>();

            ICollection<Element> walls = getElementsOfCategory(doc, BuiltInCategory.OST_Walls, ty);
            foreach (Element e in walls)
            {
                Wall w = null;
                WallType wType = null;
                w = (Wall)e;
                Assembly assem = new Assembly();
                wType = w.WallType;
                if (wType.Kind == WallKind.Basic)
                {
                    //Write Assembly Name
                    Parameter assemName = wType.get_Parameter("Assembly Description");
                    assem.AssemblyName = assemName.AsString();

                    //Write Assembly Code
                    Parameter assemCode = wType.get_Parameter("Assembly Code");
                    assem.AssemblyCode = assemCode.AsString();
                    List<AssemMaterial> mats = new List<AssemMaterial>();
                    foreach (Material m in w.Materials)
                    {
                        AssemMaterial mat = new AssemMaterial();
                        mat.Name = m.Name;
                        mats.Add(mat);
                    }
                    assem.Materials = mats;
                    foreach (Parameter p in w.Parameters)
                    {
                        if (p.Definition.Name.Equals("Area"))
                        {
                            if (p.HasValue)
                            {

                                if (assemblyAreas.ContainsKey(assem))
                                {
                                    double area = assemblyAreas[assem];
                                    totalArea += area;
                                    assemblyAreas[assem] = area + p.AsDouble();
                                }
                                else
                                    assemblyAreas.Add(assem, p.AsDouble());
                            }
                        }
                        else if (p.Definition.Name.Equals("Volume"))
                        {
                            if (p.HasValue)
                            {
                                if (assemblyVolumes.ContainsKey(assem))
                                {
                                    double vol = assemblyVolumes[assem];
                                    totalVolume += vol;
                                    assemblyVolumes[assem] = vol + p.AsDouble();
                                }
                                else
                                    assemblyVolumes.Add(assem, p.AsDouble());
                            }
                        }
                    }
                }
            }
        }