Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all parameters of Schedule and Material Takeoff

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.

Field parameters

like image 366
Mah Noor Avatar asked Dec 09 '25 09:12

Mah Noor


2 Answers

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!

like image 126
Imkc Avatar answered Dec 10 '25 21:12

Imkc


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.

like image 28
DomCR Avatar answered Dec 10 '25 21:12

DomCR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!