Get all room names from one plan view and change the parameter of a room

Get all room names from one plan view and change the parameter of a room

Anonymous
Not applicable
2,788 Views
7 Replies
Message 1 of 8

Get all room names from one plan view and change the parameter of a room

Anonymous
Not applicable

Hello, right now I am working on a project, which should get the roomnames from a plan view and compare each room name with a database. If the roomname if found in the database, the parameter in the room called "IS_IN_DATABASE" should be updated with "YES"

 

Unfortunately  I have no Idea, how to get the roomnames from one plan view...

 

I found this post: https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-rooms-filtered-by-level/td-p/6627076
but it does not work because I always get a exception: 

viewId is not a view.
Parameter name: viewId

0 Likes
2,789 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
 FilteredElementCollector room_collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType();
                IList<ElementId> room_eids = room_collector.ToElementIds() as IList<ElementId>;
                foreach(ElementId eid in room_eids)
                {
                    Room R = doc.GetElement(eid) as Room;
                    if(R.Level.Name=="Level 1" || R.Level.Name=="Level1")
                    {
                       string s=R.Name; 
                    }
                }
Message 3 of 8

Anonymous
Not applicable

Thank you so much,

I will look into it 😉

0 Likes
Message 4 of 8

Anonymous
Not applicable

thank you, so far I get every room in one level, that is exactly what I wanted, now all I need is to change a rooms parameter...

Do you know how to do that? 🙂

0 Likes
Message 5 of 8

Anonymous
Not applicable
if(R.Level.Name=="Level 1" || R.Level.Name=="Level1")
                    {
                        ParameterSet P_set = R.Parameters;
                        foreach(Parameter p in P_set)
                        {
                            if(p.Definition.Name.Equals("Your parameter name"))
                           
                                p.Set("your parameter value");
                            }
                        }
                        
                    }
0 Likes
Message 6 of 8

Anonymous
Not applicable

Thank you for your help!

Can I also use this logic for custom parameter ("parameter I defined")?

0 Likes
Message 7 of 8

Anonymous
Not applicable

I guess it will work for custom parameters also.

0 Likes
Message 8 of 8

jeremytammik
Autodesk
Autodesk

This same question is also discussed o StackOverflow:

 

https://stackoverflow.com/questions/50246737/get-all-room-names-from-one-plan-view-and-change-a-para...

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes