简体   繁体   English

如何在 Revit API 中的所有元素上设置“房间边界”属性

[英]How to set “Room Bounding” attribute on all elements in Revit API

I want to go over all elements in the document and set their "Room Bounding" attribute positive if they have a Room Bounding attribute.我想对文档中的所有元素进行 go 并在它们具有 Room Bounding 属性的情况下将其“Room Bounding”属性设置为正。

Iterating the walls I can do this:迭代墙壁我可以这样做:

Parameter param = e.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING).Set("Yes");

However how do I do that for Columns?但是,我该如何为 Columns 做到这一点? Or any other element who have this attribute?或者任何其他具有此属性的元素?

I've tried going over all elements and get their parameters using:我尝试过所有元素并使用以下方法获取它们的参数:

IList<Parameter> ps = e.GetOrderedParameters();

but which attribute do I look for?但我要寻找哪个属性? is it "Room Bounding"?是“房间边界”吗? Do I set it to "Yes" or any other thing?我是否将其设置为“是”或其他任何内容?

Edit: I first started with this: https://thebuildingcoder.typepad.com/blog/2008/09/selecting-all-w.html adjusting the code to retrive the Room Bounding parameter.编辑:我首先从这个开始: https://thebuildingcoder.typepad.com/blog/2008/09/selecting-all-w.html调整代码以检索房间边界参数。

Then changing my code to support all elements, as my question mentioned and using: https://thebuildingcoder.typepad.com/blog/2018/05/getting-all-parameter-values.html然后更改我的代码以支持所有元素,正如我提到的问题并使用: https://thebuildingcoder.typepad.com/blog/2018/05/getting-all-parameter-values.html

And I've used it to print all parameters names and their value, however I can't find the Room Bounding parameter in columns.我用它来打印所有参数名称及其值,但是我在列中找不到 Room Bounding 参数。 I could easily do it in walls.我可以很容易地在墙上做到这一点。

I tried using https://forums.autodesk.com/t5/revit-api-forum/get-the-value-of-shared-a-parameter-of-a-structural-column/td-p/8249860 and using我尝试使用https://forums.autodesk.com/t5/revit-api-forum/get-the-value-of-shared-a-parameter-of-a-structural-column/td-p/8249860并使用

mycolumnList[i].LookupParameter("Room Bounding").AsInteger() != 1)

but this also didn't work.但这也没有用。

Should I look for "Room Bounding" in instance parameter or in type parameter?我应该在实例参数或类型参数中寻找“房间边界”吗?

Please follow the standard approach to research and solve a Revit API programming task :请按照标准方法研究和解决 Revit API 编程任务

  1. Determine the optimal solution manually through the end user interface.通过最终用户界面手动确定最佳解决方案。 Make sure you follow best practices and make use of existing built-in Revit functionality.确保遵循最佳做法并利用现有的内置 Revit 功能。 If you skip this step or do not research deeply enough, you run a large risk of programming something that will be painful both to implement, maintain, debug and use.如果您跳过这一步或没有进行足够深入的研究,您将面临很大的风险,您编写的东西在实现、维护、调试和使用时都会很痛苦。
  2. Determine the names of the Revit classes, methods and properties that will help you achieve your task.确定可帮助您完成任务的 Revit 类、方法和属性的名称。 For example, create the appropriate situation and sample BIM via the user interface and analyse it before and after making the modifications you need, eg, using:例如,通过用户界面创建适当的情况和示例 BIM,并在进行所需修改之前和之后对其进行分析,例如,使用:
  3. Once you know what Revit API objects are required, learn how to access, manipulate and drive them, their relationships and how they interact with each other:了解需要哪些 Revit API 对象后,了解如何访问、操作和驱动它们、它们的关系以及它们如何相互交互:
    • Revit API help file RevitAPI.chm installed locally or online at revitapidocs.com provides detailed info on classes, properties and methods. Revit API 帮助文件RevitAPI.chm本地安装或在线安装在 revitapidocs.com提供有关类、属性和方法的详细信息。
    • Revit online help > Developers > Revit API Developers Guide explains the Revit API usage in much more depth and provides invaluable background information. Revit 联机帮助> 开发人员 > Revit API 开发人员指南更深入地解释了 Revit API 的用法,并提供了宝贵的背景信息。
    • Revit SDK sample collection installed locally and managed by Visual Studio via SDKSamples.sln shows how Revit API objects work together to solve specific tasks. Revit SDK 示例集合在本地安装并由 Visual Studio 通过SDKSamples.sln管理,展示了 Revit API 对象如何协同工作以解决特定任务。
    • The Building Coder samples provide another large bunch of sample external commands implementing numerous different tasks. Building Coder 示例提供了另外一大堆示例外部命令,它们实现了许多不同的任务。

After you have exhausted those options, search the Internet for 'revit api' or 'thebuildingcoder' plus the Revit API names that you are interested in.用尽这些选项后,在 Internet 上搜索“revit api”或“thebuildingcoder”以及您感兴趣的 Revit API 名称。

I very much hope that this addresses your question in full and does not only feed you for the moment, but also supports you in the process of being transformed into a competent future fisherman.我非常希望这能全面解决您的问题,不仅暂时满足您的需求,而且在您转变为称职的未来渔夫的过程中提供支持。

Thought I'll post a solution to help others who had similar issue.以为我会发布一个解决方案来帮助其他有类似问题的人。

Given an column e the following code change the "Room Bounding" parameter to True.给定 e 列,以下代码将“Room Bounding”参数更改为 True。 (Please notice this code do not handle exceptions) (请注意此代码不处理异常)

FamilyInstance famInst = e as FamilyInstance;
Parameter family_bound_param = famInst.LookupParameter("Room Bounding");
if (family_bound_param.AsValueString() == "No")
{                           
    using (Transaction t = new Transaction(doc, "param"))
    {
        t.Start();
        family_bound_param.Set(1);
        t.Commit();
    }
}

Thanks Jeremy for the guidance!感谢杰里米的指导!

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

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