Ayuda Contar Grupos "count groups"

Hi All,
Estoy tratando de encontrar una manera de contar los grupos, ya que cuando selecciono muchos grupos de curvas rhino me cuenta de todas las curvas, pero no todos los grupos que se encuentran seleccionados
Buscando que rhino aparesca algo como ej:
4 curvas seleccionadas dentro de un grupo

I’m trying to find a way to count the groups, because when I select many groups of rhino curves I noticed all the curves but not all groups.

Looking for something that rhino appears as an example:
4 selected curves within a group

Hi Victor,

Since each object can be in more than one group, what do you want as output if, using your example, you also had groups of circles, squares, pentagons, and ellipses, making a total of 7 groups for the 12 curves?


Hola spb
Thanks for answering
a script that selecting this shows me how many pieces have selected and not the amount of curves

solo necesito saber cuantos grupos tengo en una cantidad de piezas anidadas.
ejemplo de un solo grupo seleccionado que compone una única pieza

I just need to know how many groups have in a number of nested parts.
example of a single selected group comprises a single piece

Try this:

import rhinoscriptsyntax as rs

def main():
    idObjs = rs.SelectedObjects()
    if len(idObjs) == 0:
        print "No objects are selected."
    sGroups_AllSel = []; sGroups_SomeSel = []
    for idObj in idObjs:
        sGroups_Obj = rs.ObjectGroups(idObj)
        if len(sGroups_Obj) > 0:
            for g in sGroups_Obj:
                if g in sGroups_AllSel or g in sGroups_SomeSel: continue
                for idObj_Group in rs.ObjectsByGroup(g):
                    if not rs.IsObjectSelected(idObj_Group):
                else: sGroups_AllSel.append(g)
    print "Number of completely selected groups: {}".format(len(sGroups_AllSel))
    print "Number of partially selected groups: {}".format(len(sGroups_SomeSel))

if __name__ == '__main__': main()

Hi spb,

but it does not work in a button :frowning:

there any way I ask first select the objects

Hi Victor,

This is a known issue with running python scripts in Rhino 5 buttons.
Replace the upper last line of Steve’s code:

if __name__ == '__main__': main()


1 Like

GroupCountButtonCommand.txt (931 Bytes) will work in a button and allows post-selection.

1 Like

This is perfect thank you very much