Multiple commands automatically executed from one button/one click

Hello everyone,

I am looking for a way to chain multiple commands together automatically from one click of a button.

My current workflow involves clicking a specific point from an exploded pointcloud - using select color - grouping all those points - naming the group based on its grey scale value (0-255) - then hiding the group and repeating until all are grouped.

the three commands are -

Select by colour
Group
Set group name

I need to do this roughly 150 times per file, which means upwards of 700 clicks which takes approx 30 minutes, I would like to reduce this time.

Is there a way, either on rhino or using Python, to create a new button (as opposed to using runpython script command as this may involve an equal amount of clicks) to automatically run these three command just from one click?

the other time consuming/click consuming process is -

To find the color value for each group I need to click on the display color, then ‘other’ and type this in after using ‘setgroupname’ command, if there was a way to automatically extract the color value and type this into the ‘setgroupname’ command, that would speed things up even more, but for now I would be grateful to have the three commands run consecutively with less clicking!

Any ideas rhino experts?

Thank you,
Jed

I would think that you would want to write a python script that does this automatically with ONE selection. i.e. grab the points for each different color found, group all the same colored points and give the group a name based on the color value. Wouldn’t that be nicer?

Yes that would be ideal if it’s possible! However I don’t know anything about script writing, is this something you could help with?

Jed

Yep…

GroupPointsByColor.py (807 Bytes)

1 Like

you have just saved me hours and hours of precious life,
and you have done it in less time than it would take me to group one design. I am eternally grateful.

Jed

OK, cool, let me know if you need anything fixed/modified. This looks at the entire RGB, I noticed you mentioned grayscale, it could be therefore that objects that have the same gray value fall into different groups because they are different RGB… I think the script might be able to be modified if necessary to work on gray value…

OK Thanks, I will let you know if I run into any problems. As all the images I map to the points are already converted to grayscale using photoshop, all points have Hue/Sat at 0 and RGB and value are always identical.

e.g. looking at group labelled ‘RGB 38,38,38’ the values are H0/S0/Val38/R38/G38/B38 so there should be any issues, I would have previous just named the group 38 based on the Value, but seeing as I shouldn’t have any colors with a Hue or Sat, there shouldn’t be a issue.

One annoyance that I have with or without the script, is that when using select group, rhino lists the groups based on the first digit rather than the whole number! e.g. 2 comes after 19, and 1 comes after 255, but I can live with that.

Thanks again,
Jed

Dunno if it helps, here is a mod that adds leading zeroes to all numbers for the group name so each RGB value has 3 digits. They should then sort correctly - though it might look strange to have RGB values looking like 038,205,005.

GroupPointsByColor2.py (1.1 KB)

1 Like

That definitely helps,
it’s more satisfying having them ordered correctly, and saves me flicking back a forth through the list, particularly when finding the single digit and teen numbers which would otherwise get spread across the list.

Thank you!

Jed

For info, python strings have a method .zfill(n) which does the same as your AddLeadingZeros function, e.g;

>>> i = 20
>>> print(str(i).zfill(4))
'0020'

More on this here: https://dancergraham.github.io/blog/any-way-the-wind-blows/

2 Likes