我正试图通过Revit API获得墙上的brutto区域。 然而,我唯一得到的是netto区域。
我正在使用该方法删除墙并恢复更改以确定放置在墙上的所有元素。 然后,我将从ElementSet中删除wall的id,在变量中获取HOST_AREA_COMPUTED的值并再次恢复更改。 然而,结果是墙网区域:(参数或墙壁是否需要任何类型的重新加载?或者可能有更简单的方法来获得布鲁托区域?任何帮助将被欣赏,因为我找不到任何与该问题相关的内容。 提前致谢!
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); } }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); } }最满意答案
你走在正确的轨道上。 我建议您在删除托管元素后,需要在更新墙的参数之前重新生成。
尝试:
doc.Delete(delIds); doc.Regenerate(); // regenerate to cascade all changes. wallElem = doc.get_Element(wallElem.Id); brutto = wallElem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();如果这不起作用,那么我会说你的下一步是尝试提交子事务。 子事务完成后,您可以检索brutto wall区域,然后回滚外部事务。
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:
doc.Delete(delIds); doc.Regenerate(); // regenerate to cascade all changes. wallElem = doc.get_Element(wallElem.Id); brutto = wallElem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();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.
更多推荐
发布评论