Find levels within a given tolerance of analytical floor


I’ve been trying to create a script comparing all analytical floors to existing levels, and from there find which floors are within a certain variable tolerance of each level. From there I want to adjust the analytical floor so that it aligns to the respective levels.

I’ve managed to find the z-coordinate value (height) of the surfaces by dividing them into curves, and from there I compare it to the height of each level.

I now need to figure out firstly how to set the tolerance so that only some analytical floors show up as within the range of the level, and then go “backwards” and figure out which analytical floor is connected to the height that I have from the Z-coordinate. I can’t figure out how to do this. Recommendations appreciated :slight_smile:

Math.Round will allow for the tolerance.

Subtract after that and if it’s 0 Filter it out.

If not translate them by this measurement on the Z axis (Geometry.TranslateByDirectionDistance if I recall though I may be wrong).

This will also allow them to shift up or down if you set the math in the right order (floor minus analytical not the other way around)

1 Like

Thank you.

Do you have an idea as to how I can “go backwards” and connect which analytical floor should be alligned to the level closest to it?

have you tried getting using an Element.GetParameterValueByName node to get the “level?” If not you could get their elevation, round to your tolerance, and group them by that. If you have floors that are a ‘half’ story off than you will likely want to review manually.

1 Like

You can use a dictionary for that (see Springs.Dictionary.ByKeysValues for instance). Keys are Levels Elevations, Values are Levels Names, and Search Keys are the Point.Z of your surfaces. You should thereby get a list of levels accordingly to your initial list of analytical surfaces.
Edit: eligible Offset from Level for slabs seems to be limited to -300 to 300 mm, some kind of remapping method would be necessary if the offset is bigger

1 Like

Thank you very much for the help @Yna_Db. I’m a bit confused as to how I should interpret the results i get from the Springs.Dictionary.ByKeysValues. Could you help me out? As is now, I have 5 levels (I’m removing the top and bottom levels, giving me 3 remaining levels), and 2 analytical surfaces. Using your method, I’m getting
As far as I can tell, the “2” output is my level name (after changing the level names to something a bit more obvious…)

Changed the picture with more obvious level names.

5250 has to be flatten to 4500. This will do it, for instance:

1 Like

@A.W.A See if the example below works …

1 Like


Thank you for your input! Seems like it’s working in your case, however in my case I have fewer analytical floors than I have levels. I’m getting the results below:

Am I correct saying there should only be two outputs; the level closest to my surface no. 1, and the other should be the level closest to surface no. 2?

1 Like

List.FirstItem should be longest lacing to get the first (nearest) level from each group.

@A.W.A This should work
Note that change on the - node

1 Like

That is perfect! Working as a charm!

Thank you very much for the help, greatly appreciated! :slight_smile:

1 Like


I have tried to examine your graph and reading what it is you are asking for. I think you could solve your problem better and more efficient in another way than you have been asking.

If you have analytical floors, you also have floors… the floors know which level they are attached to (maybe set with an offset). By that, you also have their supposed level elevation.

All in all, can you solve your question very efficient by this knowledge. Try to see the below graph.

I think, however, that what you need is a constructive correction of the individual floor, so you will have you analytical floor (or the surface) in the center of the core in the floor… so I have added a correction for that as well (frozen).

Dynamo korrektion af levels.dyn (16.6 KB)

P.S. Just for the record. Anders and Kasper who is doing this, is doing a thesis on the subject of transferring data from Revit to FEM-design via Dynamo (and excel). I have encouraged them to ask questions at the forum as anybody else having a problem, although I supervise them. They should not be stuck with me just because I am busy doing something else. It was first today I have the time to look into their project to see where they are now.
I have in general asked many of our students to do the same. I use this community actively in my supervising because they will have to make it “out there” on their own. Everybody should become familiar with the forum asap :slight_smile:


While I find your solution interesting to study, something remains unclear: how do you ensure consistency between the lists of floors in analytical floors if you select them separately? In my case, and I checked it with areas values, they don’t match. Do I miss something?

thanks @Yna_Db
you are right… I should take only floors which are Structural (with analytical enabled)! otherwise will I get floors which do not have analytical floors!
When you however have that list, then it should the be the same list :slight_smile:

Not totally convinced… :slight_smile:

here is the updated…
Dynamo korrektion af levels.dyn (19.6 KB)

Try to test their elevation, that should convince you.

that the area aren’t the same is acceptable. the analytical floor should be connected to analytical points. I don’t know where you have the support for your analytical floor… looks quite strange in your example. In the example I have, is the areas coherent although they are not the same.

another trick, enable background preview… then you should be convinced :slight_smile:

Dynamo sorts automatically elements lists by IDs, which correspond to the order of the revit elements creation, and that can explain why the results are different. In my graph, as awaited, the elevations don’t match either, but the idee makes sense anyway, since we can pair floors and analytical floors by this mean :grinning:

I have now tested by deleting, setting an analytical floor, removing in all kind of random orders… and still is the floor and the analytical floor is following each other…
even making new floors some with and some without… then changed orders… the result is correct.

As I understand it, it is the creation time which will give the order objects is collected by.