GroupByKey Problem Using Sheets as Key

Hi,

I am having an issue that I hope is simple to solve.

Context:

I have 2 sheets that have multiple revision clouds with comments that act as “version” numbers that I want to populate the title block with.

Sheet 1 Revision Cloud Comments:

00A
00B
00C

Sheet 2 Revision Cloud Comments:

00A

Problem:

I want to group these “comments” by sheet. So that the list structure looks like this:

List
| [0] List
0 00A
1 00B
2 00C
| [1] List
000A

I’d like to then choose the last comment in each sheet to populate the title block. However, I am getting an error “Warning: List.GroupByKey operation failed.
Number of items does not match the number of keys.”.

Any ideas on how I can achieve a list that is grouped by sheets?

Sample Revit Project and Dynamo file can be found at this link:
https://drive.google.com/drive/folders/0B8jARoP5hB9qUHpxbll1bm8yTHc?usp=sharing

Thanks in advance.

Try to revise your solution a bit


I just added one revision without comment. If that could happen in your case then remove these instances subsequent.

I actually tried to use my own ‘RemoveNull’ (DanEDU Dynamo), but apparently, I did not have a solution that cleaned properly. Therefore, this little test made me revise my cleaning node… thanks for the challenge :slight_smile:

#cleaning nD list
def clean(items) :
	if not isinstance(items, list) :
		return items
	else :
		return [i for i in map(clean, items) if i]

#Assign your output to the OUT variable
OUT = clean(IN[0])

Postscript:
This post is some kind of connected to this post.
After updating DanEDU Dynamo package, is the nodes renamed as following:
ListClean (<- RemoveNull) and ListReplace (<- ReplaceNull)

Hi Erik,

Thank you for the quick reply. Your grouping method was perfect. Here is the solution I came up with to being able to updated the title block with the latest Revision Number (comment parameter of cloud) and Version Number (mark parameter of cloud) based on the revision clouds that are placed on the sheet.

Hopefully this is useful to someone who may experience a similar challenge.

You are welcome :slight_smile:

-first post…
Just a hint, zoom in on a few nodes and then use the camera. This way will it be possible to read your graph. As it is now, is it rather blurry. Also, is it good custom to acknowledge the ‘solution’ by marking it :wink:

-post after update by @Danku
Thanks for your graph and your nice descriptions on the graph. This is always a good way to remember what you did at a later stage in the graphs life circle and very helpful to all others.

Some hints on sharing final graphs…
Remember to write which packages you use (put a note above the ‘foreign’ nodes). For others will it be almost impossible to figure out if an image is the only thing provide. Likewise, if you update your dynamo and forget to reinstall all packages, then it is very troublesome to find the needle in the haystack, trust me :wink:

Please provide also the dynamo graph as well (.dyn file). It will also be helpful if you can provide a small example model (.rvt file). Keep such a file to the absolute minimum. Meaning, run ‘Purge Unused’ so it is as small as possible and only with content needed for the graph.

I can see a potential in optimizing your graph, if I have the time and the files, lets then see what happens :wink:

When you become more skilled and start to write your own python scripts and designscript code, then please provide also the ‘code’ as text. This way can others reuse bits and pieces without having to download things not needed. The more skilled you get, the less do you need from others to solve whatever the purpose is :slight_smile:

Thanks for the information. I agree, I think this graph can be further optimized, especially with extracting and sorting the parameter values of the most recent revisions and versions. However, this was the best I could get to solve the issue at hand with my knowledge :relaxed: The “RemoveNull” feature is definitely something I will use in the future, however some sheets do not have version but have revisions and vice versa. This probably wouldn’t have affected the script but I was in a rush. Thanks again!

Title Block Sheet Revision by Revision Cloud.dyn (28.5 KB)

Title Block Sheet Revision by Revision Cloud Reduced.rvt (2.4 MB)

Shared Parameters.txt (722 Bytes)

Hi @Danku
I have done some small adjustments :slight_smile:
-remember ‘Levels’ is a friend and dont run list trough more than needed :slight_smile:


Title Block Sheet Revision by Revision Cloud.dyn (21.3 KB)

2 Likes