Room adjacency + CalculateSpatialElementGeometry

Room adjacency + CalculateSpatialElementGeometry

Anonymous
Not applicable
7,992 Views
4 Replies
Message 1 of 5

Room adjacency + CalculateSpatialElementGeometry

Anonymous
Not applicable

Hi all,

 

I'm using the class CalculateSpatialElementGeometry to determine room/space adjacency in a Revit MEP project.

I want to know each boundary of a given room/space (wall, ceiling, floor).

 

My code is almost the same as the one used in this Wiki

Here is a part of my source code :

 

SpatialElementBoundaryOptions Opt = new SpatialElementBoundaryOptions();
Opt.StoreFreeBoundaryFaces = false;
Opt.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish;
Calc = new SpatialElementGeometryCalculator(doc, Opt);

SpatialElementGeometryResults G = Calc.CalculateSpatialElementGeometry(space);

Solid S = G.GetGeometry();

 

space is of class Space, but the problem is the same with a Room.

 

Problem : inside certain projects, it appears that the result of that code is not consistent through consecutive calls.

 

First call :

S.SurfaceArea = 162

S.Volume = 120

 

Second and subsequent calls :

S.SurfaceArea = 200

S.Volume = 250

 

Inconsistency can also be seen inside GetBoundaryFaceInfo, because SpatialElementBoundarySubface.SpatialBoundaryElement changes between calls 1 and 2+.

 

Of course, there is no modification to project database between calls.

Is it a known limitation of Revit API, or do I make something wrong ?

 

Many thanks in advance 😉

0 Likes
7,993 Views
4 Replies
Replies (4)
Message 2 of 5

mikako_harada
Alumni
Alumni
Hi Olivier,

would you like to attach a ready to build project for us to take a look?

Mikako Harada
Developer Technical Services
0 Likes
Message 3 of 5

mikako_harada
Alumni
Alumni
and a minimum rvt file that we can run with.

Mikako Harada
Developer Technical Services
0 Likes
Message 4 of 5

Anonymous
Not applicable

Hi Mikako.Harada,

 

I've solved the problem.

 

My calculation process was embedded in a transaction, and inside that transaction I was :

- Changing AreaVolumeSettings.GetAreaVolumeSettings(doc).ComputeVolumes value.

- Using SpatialElementGeometryCalculator to compute adjacencies.

 

That was the source of the inconsistency.

By isolating the modification to ComputeVolumes inside its own transaction, inconsistency has gone.

 

By the way, thanks you for your interest 😉

0 Likes
Message 5 of 5

mikako_harada
Alumni
Alumni
Excellent! I'm glad. Thank you for letting us know.

Mikako Harada
Developer Technical Services
0 Likes