Razyo
Razyo

Reputation: 69

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.

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? 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.

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

And I've used it to print all parameters names and their value, however I can't find the Room Bounding parameter in columns. 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

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?

Upvotes: 1

Views: 1737

Answers (2)

Razyo
Razyo

Reputation: 69

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. (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!

Upvotes: 2

Jeremy Tammik
Jeremy Tammik

Reputation: 8294

Please follow the standard approach to research and solve a Revit API programming task:

  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. 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. For example, create the appropriate situation and sample BIM via the user interface and analyse it before and after making the modifications you need, e.g., using:
  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 help file RevitAPI.chm installed locally or online at revitapidocs.com provides detailed info on classes, properties and methods.
    • Revit online help > Developers > Revit API Developers Guide explains the Revit API usage in much more depth and provides invaluable background information.
    • 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.
    • The Building Coder samples provide another large bunch of sample external commands implementing numerous different tasks.

After you have exhausted those options, search the Internet for 'revit api' or 'thebuildingcoder' plus the Revit API names that you are interested in.

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.

Upvotes: 0

Related Questions