I'm still on vacation, without access to a dongle, so I can't test the following.
But in general it should work the following way.
In the UI XAML you probably would use a
<Wpf:MemberSelection x:Name="objs" Height="30" Margin="0"/>
in the macro in OnLoad you need to define which routine is called when the change event is triggered, i.e.
self.objs.ValueChanged += self.selectionChanged
and then you'll put the code for selecting the items off a layer in there, i.e.
def selectionChanged(self, ctrl, e):
# first disable the event trigger, otherwise you'll end up with a loop that is calling itself all the time
self.objs.ValueChanged -= self.SelectionChanged
layermemberserials = []
# go through the selected objects
for o in self.objs: # should in theory just be one object, but maybe the user selected multiple objects
# get the layer of the of the selected object, as object
l = self.currentProject.Concordance[o.Layer]
# add the serials of all objects on that layer to the list
for sn in l.Members:
layermemberserials.Add(sn)
# potentially you could shorten the above as follows
#layermemberserials += self.currentProject.Concordance[o.Layer].Members
# clear the global selection
GlobalSelection.Clear()
# our list potentially includes duplicate serial numbers, but I believe the following is ok with that
# now set the global selection to our list of objects we've just compiled
GlobalSelection.Items(self.currentProject).Set(layermemberserials)
# reenable the event trigger
self.objs.ValueChanged += self.SelectionChanged