REVIT API - Rooms Get Boundaries Segments

REVIT API - Rooms Get Boundaries Segments

juninhopaica
Contributor Contributor
2,822 Views
6 Replies
Message 1 of 7

REVIT API - Rooms Get Boundaries Segments

juninhopaica
Contributor
Contributor

Hi there everyone, I am really new in the Revit API and I've been facing a little problema with a little charlleng i set. So i have been trying to create Floors from Rooms in Revit, and for that I used a element Collector to get all rooms in the project, and I tried to use the "GetBoundariesSegments" method to get the boundaries segment from the Rooms in the projetc. 

However, It appears that Rooms don't have a "GetBoundariesSegment"...

juninhopaica_0-1634510845647.png

 

The code Im using is the sample present in the Revit API Docs 2020 for Room Class : Room Class (revitapidocs.com) 

I tried looking for other examples, trying to convert the elements in collector from Autodesk.Revit.DB.Elements to Autodesk.Revit.DB.Architecture.Room in order to use the methods, and even see if I was missing a directive or assembly method. 

Can someone help me with this? Thanks for the patience with me, I am a begginer so this can be really simple for most of the people out there...

 

0 Likes
Accepted solutions (1)
2,823 Views
6 Replies
Replies (6)
Message 2 of 7

AGGilliam
Collaborator
Collaborator

If you look at that first error, it's trying to convert Autodesk.DesignScript.Geometry.Point to Autodesk.Revit.DB.LocationPoint. The reference to Room that you're using appears to be from the wrong namespace (DesignScript instead of Revit). Add Autodesk.Revit.DB.Architecture. in front of Room and you should be set.

private void Getinfo_Room(Autodesk.Revit.DB.Architecture.Room room)

 

Message 3 of 7

Omar_Amen
Advocate
Advocate

I'm just wondering, from which assembly dose the namespace "Autodesk.DesignScript.Geometry..." come from ?!
dose it related to the dynamo/python for Revit ?

0 Likes
Message 4 of 7

AGGilliam
Collaborator
Collaborator

I'm not sure since I've never seen it before, but I did a quick Google search and it looks like it's from the ProtoGeometry.dll file that comes with Dynamo. Here's the link I used if you're curious.

Message 5 of 7

juninhopaica
Contributor
Contributor

I see, that really solved one problem!

 

juninhopaica_0-1634566220319.png


However I found other right after that. When using a collector with a Roomfilter to get all Rooms in a specific project, the objects that I get returned are actually (Autodesk.Revit.DB.Elements), and not (Autodesk.Revit.DB.Architecture.Rooms) and the later don't have a "GetBoundariesSegment" method. Here is the method to collect all rooms that I used...

juninhopaica_1-1634567122516.png


I used the RoomFilter (RoomFilter Class (revitapidocs.com)) which is actually a slow filter, and has a sample for use. I tried to convert the elements from Autodesk.Revit.DB.Element to Autodesk.Revit.DB.Architecture.Room but with no succsse...


Im sorry to bother with another question, but how would we be able to use Room elements from the filter ? Thanks for the help, is really nice to see that the community here is so recepitive!

0 Likes
Message 6 of 7

AGGilliam
Collaborator
Collaborator
Accepted solution

I don't see where the issue is, where are you trying to convert Element to Room? You should be able to do that fairly easily. The way I usually go about it when using a Filtered Element Collector is by Casting to the type I need and sending it to a list. (You'll need a reference to System.Linq for this).

List<Room> list = collector.WherePasses(filter).Cast<Room>().ToList();

 However, reassigning an Element to a Room variable while iterating over the collection should also work just as well. What issues were you having with it? 

0 Likes
Message 7 of 7

juninhopaica
Contributor
Contributor

Yes I was actually having a hard time with casting the type, but you really cleared the problem for me...
I'm a Civil Engineer, but just recently I got in the area of programing, because of that I am still getting the hang of some definitions and concepts... 

I did did not realize that we could use the cast type... Thank you so much my friend, god bless you