I am trying to make a tool that compare’s items inside of solids with each other. So the tool has to sort the sublist by items inside the sublist. this is what i have now but it doesnt work i also tried to use keys but i do not understand how that works. this is what i have now:
it works but it will only check if the key value of the first item in the sublist is the same and not if the rest of the items in the sublist are the same and have the same amount of items right?
Right. If you want the full list to be what drives it you will need to either convert your data to something comparable (i.e the XYZ values of a point concatenated into a single string) or live with the accuracy which String.FromArray or String.FromObject + concatenation provide. The resulting string representation becomes your keys.
So if you want to use String.FromArray replace the List.FirstItem with that node and you should be all set - just watch your list levels.
I feel like i have tried every level by now with stringFromArray and i still do not get it to work. It will only make keys and groups if i put my list on L4 and sortbykey also does not work rn.
You could make a range of same length, index that, then feed to getitematindex as well if you want to group/sort original lists in the same manner as their original key.
This is what i am looking for but i have a problem; 2 elements inside of the list are Null in string.Concat these are a line and a solid. i need these 2 dynamo element’s later in the script (they have to get sorted with the rest and are for making scopeboxes with for 3d views and 3d revit lines with that show on drawing) i have a script that takes the sorted lines and make’s for evert type a new line type so u can detect it in a drawing. is there any way around it?
Your list structure appears to be more complex than your initial example. We will need a sample model and script to see what you’re working with I think.
How are you generating the strings? Note that a string representation of a cuboid can be “solid”, and that a string representation of a sphere can be “solid” so your goal might not be attainable.
I have a sneaking suspicion that a dictionary or another method of object management might be better suited.
no i also need the line and the solid i use the solid to get item at index 0 and make scope boxes in revit for views with them and i use the line’s for placing specific line’s on the revit drawing
The problem I see is that if the solids are not the same you’ll be in trouble.
Rectangle.ByWidthLength(1,1).ExtrudAsSolid(1) + “”; returns “solid”, and Circle.ByCenterPoint.Radius(Point.Origin(),1).ExtrudeAsSolid(1) + “”; also returns “solid”. As a result if the four other keys all match these will be grouped together even though they are different.
If there is any chance this could happen with all the datasets you could ever process, then you need to come up with a new approach.
What is it you are trying to do in the ‘big picture’ sense?
I am making solid boxes on the side’s of elements. (already have a good working script for that)
I compare the elements inside the boxes to compare if the connection points are the same or if it has a other type of connection. (already have a script working but it does not infinit scale only by making spaghetti code this code does not work with keys but with string.contains and list count to determine if the connection is the same:
Lines beacome modelcurve with their own name and are visible on drawing so u know where connection is (so that is y i need them to be sorted)
Boxes i take the first box of every list of list and it for making 3d viewboxes and 2d sections after that they i create a sheet with those 2 views
i am just trying to clean up my code a bit. and making it so i dont have to manualy scale it like the old code (this is the old code)