Not applicable
07-31-2018
09:18 AM
Hi.
In Revit SDK 2019. I am trying to recover the ID or name of the materials used in the walls of a project to then make budgets according to the price per square meter of the material and the area of the wall.
public void SetTypeParameter(Document doc) { Element e = FindElementByName(doc, typeof(Material), "SW48"); UIDocument uidoc = new UIDocument(doc); Reference myRef = uidoc.Selection.PickObject(ObjectType.Element, "Selecciona un elemento"); Element m = doc.GetElement(myRef); Wall pared = doc.GetElement(m.Id) as Wall; Material material = doc.GetElement(e.Id) as Material; double total; foreach (Parameter para in pared.Parameters) { TaskDialog.Show("revit", para.Definition.Name + " - " + para.AsValueString()); } try { using (Transaction t = new Transaction(doc, "Set Type")) { t.Start(); Parameter p = material.get_Parameter(BuiltInParameter.ALL_MODEL_COST); Parameter area = pared.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED); string MyString =area.AsValueString(); string NewString = MyString.Remove(2,3); total = ((p.AsDouble() * Convert.ToDouble(NewString))); p.Set(360); TaskDialog.Show("Precio", "Precio del material por m2: " + p.AsValueString()+"\n Area total del muro: "+area.AsValueString()+"\n Precio total: $"+total ); t.Commit(); } } catch (Exception ex) { TaskDialog.Show("error ", ex.Message); } }
In the code, I manually recover the cost of the "SW48" material. Is there a way that when selecting the wall I recover the material that is being used? Thank you.
Solved! Go to Solution.
Link copied