Script Select objs with same name in same group

 From:  Michael Gibson
11274.3 In reply to 11274.1 
Hi Nos,

re:
> Has anyone an idea how to modify the code below to select all objects with the same
> name but restrict it to the same group?

Maybe an easy way for this case could be to mark a combination of the object name and the parent group's id instead of just object name. That way only objects with both that name and in the same group would match.

So like this (warning untested code):

code:
/* Extend selection to same names */
var names = new Array();
var objs = moi.geometryDatabase.getSelectedObjects();

for (var i = 0; i < objs.length; ++i) {
    var obj = objs.item(i);
    if (obj.name != '' && obj.ownerGroup) {
        names[obj.name + obj.ownerGroup.id] = true;
    }
}

objs = moi.geometryDatabase.getObjects();
for (var i = 0; i < objs.length; ++i) {
    var obj = objs.item(i);
    if (obj.name != '' && obj.ownerGroup && names[obj.name + ownerGroup.id]) {
        obj.selected = true;
    }
}


  - Michael

EDITED: 4 Dec 2023 by MICHAEL GIBSON