delete / remove face of a BRep in a script

 From:  pressure (PEER)
10995.1 
I'm trying to delete one face of a solid and then do something else with the resulting object in a script. I don't understand how the delete factory works.

I can successfully delete a selected face and be left with an object that looks like the original solid less one face:

code:
var faces = moi.geometryDatabase.getSelectedObjects().getFaces();

// delete original face
var factory = moi.command.createFactory( 'delete' );
factory.setInput( 0, faces );
var facelessParent = factory.commit();


But if I try to get the new object that exists after deleting the face I run into trouble:

code:
var faces = moi.geometryDatabase.getSelectedObjects().getFaces();

// delete original face
var factory = moi.command.createFactory( 'delete' );
factory.setInput( 0, faces );
var facelessParent = factory.calculate();
moi.geometryDatabase.addObjects( facelessParent );


Specifically, the combination of .calculate() and .addObjects ( object ) results in 2 objects existing: a solid that looks like the original solid and a solid less one face. I can do what I want with the new object facelessParent, but I have to do another deletion to get rid of the solid that remains in the scene. I thought that maybe the delete factory is returning an ObjectList with more than 1 object, but that doesn't seem to be the case.

What's the right way to delete a face of a BRep and then doing something additional to the new BRep?

- Peer