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
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.
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
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…)
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?
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?
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
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?
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…