Find levels within a given tolerance of analytical floor

Hi!

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

@Vikram_Subbaiah

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

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?

Not totally 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:

At least, that’s what I have in mind, but I never explored this into details. I remember having read something about this once, maybe on Jeremy Tammik blog, I will check if I can find it back…

The floor will follow the analytical floor and vice versa?

We shouldn’t be very far from that :slightly_smiling_face:

1 Like

For clarity, here is a very good thread about IDs (and unique IDs):
https://forums.autodesk.com/t5/revit-api-forum/understanding-the-use-of-the-uniqueid/m-p/5474167/thread-id/8346
Especially, you will find this in post 2: "Ids are never reused. If an element is deleted, its Id will not be used for anything else."
Of course, it does not mean that IDs are created in a logical order, but I think that I came to this conclusion by looking at the list while creating elements. Any further information would naturally be welcome.

And I also forgot to mention that a new topic should probably be created for such a discussion… :slightly_smiling_face: