I’m trying to get the wall brutto area with Revit API. However the only thing I’m getting is the netto area.
I’m using the method with deleting the wall and reverting the changes to determine all the elements that are placed on the wall. Then, I’m removing the wall’s id from the ElementSet getting the value of HOST_AREA_COMPUTED in a variable and reverting the changes again. The result, however, is the wall netto area 🙁
Does the parameter or wall needs any kind of reload? Or maybe there’s easier way to get the brutto area? Any help would be appreciated as I can’t find anything related to that problem. Thanks in advance!
foreach (Wall wallElem in elems)
{
try
{
Double brutto = 0.0;
ICollection<ElementId> delIds = null;
using (SubTransaction t = new SubTransaction(doc))
{
try
{
t.Start();
delIds = doc.Delete(wallElem);
t.RollBack();
}
catch (Exception ex)
{
message = "Deletion failed: " + ex.Message;
t.RollBack();
}
}
using (SubTransaction u = new SubTransaction(doc))
{
try
{
u.Start();
delIds.Remove(wallElem.Id);
doc.Delete(delIds);
brutto = wallElem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
u.RollBack();
}
catch (Exception ex)
{
message = "Deletion failed: " + ex.Message;
u.RollBack();
}
}
wallElem.get_Parameter("Wall Area Bruto").Set(brutto);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
You’re on the right track.
I would suggest that after you delete the hosted elements, that you need to regenerate before the parameters for the wall will be updated.
Try:
If this doesn’t work, then I would say your next step would be to try committing the subtransaction. After the subtransaction completes, you may be able to retrieve the brutto wall area, and then Rollback() the outside transaction.