You need to first find a member field or a datablock property that distinguishes the brick you want to be deleted from other bricks. Then, loop through all bricks and delete the ones that have that distinguishing property
He's right.
In this case, all trench dirt brick datablocks have an
isTrenchDirt variable set to true.
So, you'd do something like this:
%mct = MainBrickGroup.getCount();
for(%i = 0; %i < %mct; %i++)
{
%obj = MainBrickGroup.getObject(%i);
if(!%oct = %obj.getCount())
continue;
for(%x = 0; %x < %oct; %x++)
{
%b = %obj.getObject(%x);
if(%b.getDatablock().isTrenchDirt)
%b.delete();
}
}
I'm not guaranteeing that will work, but it should give you an idea of where to go with this.