Search code examples
c#autodesk-forgerevit-apiautodeskrevit

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?


Solution

  • 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!