Revit / Dynamo-Skript sortieren bevor Set.Parameter

Revit / Dynamo-Skript sortieren bevor Set.Parameter

Lennard_Kemper
Participant Participant
435 Views
6 Replies
Message 1 of 7

Revit / Dynamo-Skript sortieren bevor Set.Parameter

Lennard_Kemper
Participant
Participant

Hallo zusammen,

ich versuche seit ein paar Tagen mein erstes Dynamo-Skript zu erstellen.

Es soll aus meinem Projekt die Kategorie "Brandmelder" ausgelesen werden, den Familien der Kategorie habe ich einen Parameter "Nummer" gegeben. Nun soll das Skript alles aus der Kategorie "Brandmelder" suchen, hiervon die Absolute Z-Koordinate finden und nach dieser sortieren.

Danach soll in sortierter Reihenfolge der Parameter "Nummer" von 1 bis x gefüllt werden.

 

Ich bekomme es hin das der Parameter gefüllt wird, aber leider nicht nach der gewünschten sortierung sondern in der Reihenfolge wie ich die Objekte platziert habe.

 

grafik.png

Der obere Teil gibt mir eine sortierte Liste aus, so wie es sein soll.

Der Teil SetParameterByName funktioniert soweit auch, 

aber ich weiß leider nicht wie ich es hinbekomme das erst die sortierung ausgeführt wird und danach anhand der sortierten Liste die Nummerierung ausgeführt wird.

 

Ich hoffe hier kann mir jemand helfen und die Lösung nennen.

 

Grüße

Lennard

0 Likes
Accepted solutions (2)
436 Views
6 Replies
Replies (6)
Message 2 of 7

iainsavage
Mentor
Mentor

I'm not an expert on this but it seems to me that you are applying the setparameterbyname node to the unsorted list.

You need to use the sorted list so I'm suggesting it would be something like this:

iainsavage_0-1737972531925.png

It might not be quite as simple as that though.

@RLY_15 could maybe help better.

0 Likes
Message 3 of 7

Lennard_Kemper
Participant
Participant

I have already tried this, but then I get the following error message: Element.SetParameterByName expects argument type(s) (Revit.Elements.Element, string, var), but was retrieved with (double[], string, int[])

0 Likes
Message 4 of 7

iainsavage
Mentor
Mentor

I thought that might be the case because you would only be inputting the Z values rather than the elements connected to those values.

I think I solved something similar to this before using a dictionary rather than a sorted list. The dictionary contains pairs of values, one would be the key (Z value) and the other would be the element identifier. You could then, I assume sort the order of the dictionary pairs then output the element IDs to your setparameter node.

Again though someone else might have more experience of this.

There's also a separate forum at https://forum.dynamobim.com/ which you could search or post on.

0 Likes
Message 5 of 7

RLY_15
Advisor
Advisor
Accepted solution

Sort the list of elements using the Key of Z-values. The list input on SortByKey looks like it's taking the Point.Z node twice.

 

workspace.png

0 Likes
Message 6 of 7

iainsavage
Mentor
Mentor

Actually thinking about it again a dictionary probably wouldn't work because the keys have to be unique so you couldn't have two or more elements with the same Z value in a dictionary.

0 Likes
Message 7 of 7

Lennard_Kemper
Participant
Participant
Accepted solution

The answer from @RLY_15 helped me solve my problem. Now I can concentrate on making improvements.

 

This is my solution:

Lennard_Kemper_0-1738046754834.png