Ejemplo n.º 1
0
 /// <summary>
 /// Get the material type via giving material.
 /// According to my knowledge, the material type can be retrieved by two ways now:
 /// 1. If the PropertySetElement exists, retrieve it by PHY_MATERIAL_PARAM_CLASS parameter. (via PropertySetElement class)
 /// 2. If it's indenpendent, retrieve it by PHY_MATERIAL_PARAM_TYPE parameter(via Material class)
 /// </summary>
 /// <param name="material"></param>
 /// <returns></returns>
 private StructuralAssetClass GetMaterialType(Material material)
 {
     if (material.StructuralAssetId != ElementId.InvalidElementId)
     {
         PropertySetElement propElem     = m_revit.ActiveUIDocument.Document.GetElement(material.StructuralAssetId) as PropertySetElement;
         Parameter          propElemPara = propElem.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS);
         if (propElemPara != null)
         {
             return((StructuralAssetClass)propElemPara.AsInteger());
         }
     }
     return(StructuralAssetClass.Undefined);
     //ElementId propElemId = material.GetMaterialAspectPropertySet(MaterialAspect.Structural);
     //if (ElementId.InvalidElementId == propElemId)
     //{
     //    Parameter independentPara = material.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_TYPE);
     //    if (null == independentPara)
     //    {
     //        return MaterialType.Generic;
     //    }
     //    return (MaterialType)independentPara.AsInteger();
     //}
     //PropertySetElement propElem = m_revit.ActiveUIDocument.Document.GetElement(propElemId) as PropertySetElement;
     //Parameter propElemPara = propElem.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_CLASS);
     //if (null == propElemPara)
     //{
     //    return MaterialType.Generic;
     //}
     //return (MaterialType)propElemPara.AsInteger();
 }
Ejemplo n.º 2
0
        public static double GetMaterialDensity(Document doc, ElementId materialId)
        {
            Material material = doc.GetElement(materialId) as Material;

            if (material.StructuralAssetId == ElementId.InvalidElementId)
            {
                string msg = "Не заданы Физические свойства материала " + material.Name;
                System.Windows.Forms.MessageBox.Show(msg);
                throw new Exception(msg);
            }
            PropertySetElement materialStructuralParams = doc.GetElement(material.StructuralAssetId) as PropertySetElement;
            double             density = materialStructuralParams.get_Parameter(BuiltInParameter.PHY_MATERIAL_PARAM_STRUCTURAL_DENSITY).AsDouble();

            return(density);
        }
Ejemplo n.º 3
0
        public static CarboElement getNewCarboElement(Document doc, Element el, ElementId materialIds, CarboRevitImportSettings settings)
        {
            CarboElement newCarboElement = new CarboElement();

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

                // 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
                setImportedMaterialName = 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();
                                newCarboElement.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 = setImportedMaterialName;
                newCarboElement.Category     = setCategory;
                newCarboElement.SubCategory  = setSubCategory;
                newCarboElement.Volume       = Math.Round(setVolume, 4);
                //newCarboElement.Material = carboMaterial; //Material removed
                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
            {
                //TaskDialog.Show("Error", ex.Message);
                return(null);
            }
        }