Get all parameters of Schedule and Material Takeoff

独自空忆成欢 提交于 2021-02-05 07:10:23

问题


I am creating plugin for Revit 2019 and want to get all the parameters of Wall Category. I have filtered the walls and then I am accessing parameters of wall. But I am not getting the parameters like "Material: Name, Material: Area, Material: Volume" etc

I have tried the following code

ElementFilter wall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
    ICollection<Element> walls = new 
    FilteredElementCollector(doc).WherePasses(wall).ToElements();

string prompt = "Parameters";
foreach (Element e in walls)
{    
        ParameterSet pSet = e.Parameters;

        foreach (Parameter p in pSet)
        {
            prompt += (p.Definition as 
     InternalDefinition).BuiltInParameter.ToString();
            prompt += Environment.NewLine;
        }

        break;
    }
 }

I have also tried the following method:

IList<Parameter> orderedParameters = e.GetOrderedParameters();

And also this:

ParameterMap parameterMap = e.ParametersMap;

I want to get all parameters including schedule and take off parameters.

I am not getting the highlighted parameters.


回答1:


I don't know about some of the element specific parameters like Area, As Paint and Volume, but at least some of them are accessible by getting the material of the wall and also accessing the parameters of the material instead of just your wall.




回答2:


WallType type = WallTypes.ElementAt(0) as WallType;
WallType newType = type.Duplicate(name) as WallType;
CompoundStructure cs = type.GetCompoundStructure();
CompoundStructure wallComPound = newType.GetCompoundStructure();
foreach (CompoundStructureLayer layer in wallComPound.GetLayers())
{
layer.Width = value ;
wallComPound.SetLayerWidth(layer.LayerId, layer.Width);
break;
}
newType.SetCompoundStructure(wallComPound);

this demo is change wall's width,If I understand you correctly, you want to get material parameter,in wall,you should get the walltype and then you should get the compoundStructural ,in this ,youcan get the martral information.Beacuse wall is Consists of several layers of information。Hopefully it helped you!




回答3:


You can get this from the wall without, there is no need to access the parameters.

foreach (Element e in walls)
{    
    double area = e.GetMaterialArea();
    double volume = e.GetMaterialVolume();
    //Get the category material
    Material mat = e.Category.Material;
}

If you want to get all the information of the material you can use GetMaterialIds()

foreach(ElementId id in e.GetMaterialIds())
{
    Material mat = doc.GetElement(id) as Material;
    //Get data from material...
}

For more information check the api.



来源:https://stackoverflow.com/questions/57248450/get-all-parameters-of-schedule-and-material-takeoff

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!