Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Direct Shape from Room

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
thomashachler
3059 Views, 11 Replies

Create Direct Shape from Room

 

 

How can I create Direct Shape from rooms with holes ?

 

I read many discussion and post but I wasn't able to solve the problem ! Smiley Frustrated

 

More info and source in this issue :

https://github.com/Tamu/Revit3Drooms/issues/1 

 

Source code :

https://github.com/Tamu/Revit3Drooms

 

Last reading :

2d-polygon-areas-and-outer-loop

create-mass-from-room

 

Many thanks for help !

11 REPLIES 11
Message 2 of 12

Dear Platform5rd,

 

Thank you for your interesting query.

 

It is not completely clear to me what exactly you are after.

 

If you want the room with holes, then there will be nothing left.

 

The room is a hole.

 

What else is a room except a hole?

 

Do you mean that you would like to recreate the shape of all the walls with their openings?

 

Do you mean that you have a room whose plan view includes holes?

 

Let's assume the latter.

 

In that case, if your walls are all vertical, this is absolutely trivial.

 

You can collect the room boundary edges and assemble them into the outer and inner wall loops.

 

This is demonstrated very effectively by the 2D room editor, which retrieves this information, converts it to a simplified 2D view in SVG, and displays the room outline in a web browser:

 

https://github.com/jeremytammik/RoomEditorApp

 

Here is a demo recording and lots of other supporting material:

 

http://thebuildingcoder.typepad.com/blog/2016/10/connecting-desktop-and-cloud-at-rtc-material.html

 

If you want a 3D direct shape instead of a 2D flat version, you will obviously need to determine the ceiling height and location and take that into account as well.

 

I hope this helps.

 

Update:

 

OK, I now went and read your problem description.

 

🙂

 

Very clear. Thank you for that.

 

Thank you also for your appreciation!

 

That issue is indeed addressed by the RoomEditorApp that I already pointed to.

 

When you retrieve the room boundary, the edges may not be contiguous in the right order.

 

You may need to order them yourself.

 

There are several ways of achieving that:

 

  1. DIY. I love do it yourself. Search for SortCurvesContiguous.

 

  1. ExporterIFCUtils.ValidateCurveLoops. Maybe. The Edge.AsCurveFollowingFace method. Maybe. But read on through the following, and note the note in the last of the discussions listed below.

 

For the former, here is some reading material:

 

2D Polygon Areas and Outer Loop -- http://thebuildingcoder.typepad.com/blog/2008/12/2d-polygon-areas-and-outer-loop.html

 

Curve Following Face and Bounding Box Implementation -- http://thebuildingcoder.typepad.com/blog/2013/03/sort-and-orient-curves-to-form-a-contiguous-loop.ht...

 

Retrieving Plan View Room Boundary Polygon Loops -- http://thebuildingcoder.typepad.com/blog/2013/03/revit-2014-api-and-room-plan-view-boundary-polygon-...

 

Extrusion Analyser and Plan View Boundaries -- http://thebuildingcoder.typepad.com/blog/2013/04/extrusion-analyser-and-plan-view-boundaries.html

 

Room and Furniture Loops Using Symbols -- http://thebuildingcoder.typepad.com/blog/2013/04/room-and-furniture-loops-using-symbols.html

 

https://github.com/jeremytammik/RoomEditorApp/blob/master/RoomEditorApp/ContiguousCurveSorter.cs

 

Sorting Face Loop Edges -- http://thebuildingcoder.typepad.com/blog/2015/01/autodesk-internship-in-california-and-sorting-edges...

 

I have explored and written lots more on this topic, as you can see if you follow the various links in the discussions listed above.

 

I am confident that this will give you all you need.

 

I see that what you are after is basically the floor slabs under the rooms.

 

I assume that you are not interested in querying the slabs for their geometry?

 

You want to create these shapes form the room boundaries?

 

Well, I think you have all you need now for that.

 

Good luck and have fun!

 

Best regards,

 

Jeremy



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

Message 3 of 12

Thanks Jeremy !

 

 

"Do you mean that you have a room whose plan view includes holes?"

 

Yes, I would like to create the volume of the room. If the room has holes (Because walls), I would also like to subtract the volume of the hole.

 

In short, I feel ... that you translated perfectly my strange English !

 


"You want to create these shapes form the room boundaries?"

 

Yes, exactly. For the elevation, I need only a fixed height (very simple).

 

 

I go back to work !

 

Message 4 of 12

Here is the solution : 

It was necessary to add in the Boundary loop : curveLoopList.Add(curveLoop);

 

 

 

 

 foreach (IList<BoundarySegment> b in boundaries) // 2012
                            {
                                List<Curve> profile = new List<Curve>();
                                ++iBoundary;
                                iSegment = 0;

                                foreach (BoundarySegment s in b)
                                {
                                    ++iSegment;
                                    Curve curve = s.GetCurve(); // 2016

                                    profile.Add(curve); //add shape for instant object

                                }


                                try
                                {
                                    CurveLoop curveLoop = CurveLoop.Create(profile);
                                    curveLoopList.Add(curveLoop);
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(ex.Message);
                                }

                            }

 

Full code/demo : https://github.com/Tamu/Revit3Drooms

 

Message 5 of 12
Anonymous
in reply to: thomashachler

Maybe Im missing something here, but why cant you use the SpatialElementGeometryCalculator?
That gives you the solid you require for the DirectShape immedietly, I've used this for quite a few implementations.
Does this not take holes into account?

Message 6 of 12
thomashachler
in reply to: Anonymous

Hi Erik,

 

The SpatialElementGeometryCalculator works for Rooms ?

 

For a general case this works well but I did not succeed for rooms. Have you already tried ?

 

Best regards,

Thomas

 

Message 7 of 12
Anonymous
in reply to: thomashachler

I havent read through all your material, so Im not sure about if your specific case needs something special, but it can extract solid geometry and I havent seen any drawbacks.
The Room type directly inherits SpatialElement so yes it sure works.

Here is a sample from the documentation:

 

// Calculate a room's geometry and find its boundary faces
SpatialElementGeometryCalculator calculator = new SpatialElementGeometryCalculator(doc);
SpatialElementGeometryResults results = calculator.CalculateSpatialElementGeometry(room); // compute the room geometry 
Solid roomSolid = results.GetGeometry(); // get the solid representing the room's geometry
foreach (Face face in roomSolid.Faces)
{
    double faceArea = face.Area;
    IList<SpatialElementBoundarySubface> subfaceList = results.GetBoundaryFaceInfo(face); // get the sub-faces for the face of the room
    foreach (SpatialElementBoundarySubface subface in subfaceList)
    {
        if (subfaceList.Count > 1) // there are multiple sub-faces that define the face
        {
            double subfaceArea = subface.GetSubface().Area; // get the area of each sub-face
            // sub-faces exist in situations such as when a room-bounding wall has been
            // horizontally split and the faces of each split wall combine to create the 
            // entire face of the room
        }
    }
}
Message 8 of 12
thomashachler
in reply to: Anonymous

 

Thank you very much ! That seems really good !

 

The only special thing : I must have a cut to 1 ft from the floor

Message 9 of 12
Anonymous
in reply to: thomashachler

The BooleanOperationsUtils class gives you some options where I think the CutWithHalfSpace seems like the most useful one.
However, I mean, if your code works, then go for it. I was just hinting at a more easy solution for future use.

And I also want to see if Jeremy (or another Autodesk employee) has anything to say about wether SpatialGeometryElementCalculator has any limitations...

Message 10 of 12
thomashachler
in reply to: Anonymous

 

Thank you for your good solution !

Message 11 of 12
jeremytammik
in reply to: Anonymous

Dear Thomas,

 

Thank you for fleshing out and sharing the initial solution based on the room boundary curves in

 

https://github.com/Tamu/Revit3Drooms

 

Dear Erik,

 

Thank you very much for jumping in and providing a much more efficient solution based on the SpatialElementGeometryCalculator and CutWithHalfSpace.

 

Thomas, can you summarise in a few words why you prefer the latter?

 

I am sorry I pointed you in the wrong direction!

 

I would like to keep track of this comparison for future reference.

 

Will you update your Revit3Drooms sample to use the SpatialElementGeometryCalculator instead?

 

Or publish a new solution entirely?

 

Or maintain two branches to highlight the differences?

 

Erik, I am not aware of any SpatialGeometryElementCalculator limitations.

 

All I know about it is summarised in the SpatialElementGeometryCalculator GitHub repo and the blog posts that it points to:

 

https://github.com/jeremytammik/SpatialElementGeometryCalculator

 

As far as I can tell so far, this thread is worthwhile preserving and adding to that list...

 

Thank you both!

 

Cheers,

 

Jeremy



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

Message 12 of 12

Thanks Jeremy for your help ! I learn a lot with this challenge !

 

I will try to create two branches to highlight the differences.

 

Cheers,

Thomas

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report