Im currently working with assemblies with lots of rebar. i need to number these rebar so i can reach a proper rebar list (see pic 1)
The problem is some rebars are duplicates and im unable to do this using just dynamo blocks. So i thought i might aswell give Chatgpt a shot to make me a phyton script.
I tried the script and nothing literally output was 0.
Does anybody have any experience with this? script from chatgpt below.
Prompt:
Looking to build a Python script in side Dynamo for Revit to help with a “match” functionality similar to Excel. Input 1 would be a list of strings that can contain duplicate values. Input 2 would be a 2-dimensional list where the first dimension contains the unique values from Input 1 and the second dimension a simple number. The output should contain a list with the same amount of entries as Input 1 where each item of the list contains the value of the second dimension of input 2, corresponding to the same index as the match between the actual value for that item of Input 1.
def match_functionality(input1, input2):
# Convert Input 2 into a dictionary for fast lookup
lookup_dict = {item[0]: item[1] for item in input2}
# Generate the output list by matching Input 1 values to the dictionary
output = [lookup_dict.get(value, None) for value in input1]
return output
# Example inputs
input1 = ["A", "B", "A", "C", "B"] # List with duplicate values
input2 = [["A", 1], ["B", 2], ["C", 3]] # 2D list with unique values and corresponding numbers
# Call the function
output = match_functionality(input1, input2)
# Print the output
print(output)
Why do you have duplicates / what do you mean by this. My guess there is an (easy?) non Python solution for this.
Dictionaries and group by keys is what you probably should look into in Dynamo.
Still little unclear what end result you are after.
Also what do the letters (A,B, C etc.) resemble?
PS
I really advice to starting Dynamo first instead of going fir (asking) ChatGPT. I don’t think ChatGPT is that great with just a little Dynamo knowledge. Just my two cents.
You don’t output anything from your code. The print() method will print to the console log but that’s not the same as outputting from the node. You need to use OUT to return an output.
OUT = output
Beyond that, I agree with @bvs1982, you need to provide more information and should probably avoid ChatGPT until you know what you’re looking for.
What counts as a duplicate? Nothing in your table looks like a duplicate. How is your data structured? If it doesn’t look like the example inputs then your code won’t work anyway.
my table was just a simple example. the wall elements have a lot more rebar which would go over 40 different types.
So when i tried to auto number (setparameter → mark) i sorted the Ø, length and shape. but because theres duplicates the numbers go over 50 in some elements which isnt handy for productions plans.
Ill share the dynamo file i orginially created shortly. this is the one that doesnt spot duplicates and assigns them the same mark tho
What I understand is you are trying to create a rebar schedule (sorted by dia, length and then shape), and add a mark value for each row? for example if your assembly has 1500 rebars and after sorting 50 types (rows) are created and you want to number them 1 to 50. is that correct?
I worked on the same script when I started learning dynamo.
You first sort the rebar elements by bar dia parameter and then sort this list by length keeping the list structure same, do the same for next parameter.
you will need to play around list levels but here’s a quick tip, the number of elements in the list should be the total number of rebars in your assembly.
one thing to note is that do the sorting in dynamo the same way you would in Revit. so the mark values are shown in order. Add Rebar Mark.dyn (51.5 KB)
Just to add to this topic. Instead of sorting through Bar Length i’ve sorted through Length Parameters “A”, “B” and “C”. I had an error because some shapes (for example shape 21) had similar bar lengths but different A and B length parameters.
I’ve made some outputs to check how many dupes each rebar mark has. and i have several rebar types (precastembedded, in situ, precastloose) in my project to check if the right types are present and got a mark / number.
I am working out how to combine length parameters a b and c in one sorting progress.