简体   繁体   English

在Revit API中获取墙面Brutto区域

[英]Getting wall brutto area in Revit API

I'm trying to get the wall brutto area with Revit API. 我正在尝试使用Revit API来获取Wall brutto区域。 However the only thing I'm getting is the netto area. 但是,我唯一得到的就是netto区域。

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. 然后,我从ElementSet中删除墙的ID,并在变量中获取HOST_AREA_COMPUTED的值,然后再次还原更改。 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! 但是,结果是wall netto区域:(参数或wall是否需要任何类型的重载?或者也许有更简单的方法来获取brutto区域?由于我找不到与该问题相关的任何信息,将不胜感激。 提前致谢!

        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);
            }
        }

Have you tried just looking at the geometry? 您是否尝试过仅查看几何? If you take the walls solid and look through the faces, there should be two faces that are way bigger than all the other faces and have a zero z component for their orientation - the area of one of these faces should be your brutto area! 如果您将墙作为实心并仔细查看这些面,则应该有两个面比所有其他面大得多,并且其方向的z分量为零-这些面之一的面积应该是您的brutto面积!

BUT : specific to your question, you might try to re-fetch the wall element from the document: 但是 :针对您的问题,您可以尝试从文档中重新获取墙元素:

delIds.Remove(wallElem.Id);
doc.Delete(delIds);
wallElem = doc.get_ElementById(wallElem.Id); // re-fetch wall element from BIM model
brutto = wallElem.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
u.RollBack();

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. 子事务完成后,您可以检索brutto墙区域,然后再Rollout()进行外部事务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM