What kind of trouble do you run into, specifically? I've just tried it and if there are no topology-changing modifiers it seems to work as expected. It might be better to get the obj.mesh face count instead so that it would work with primitive objects as well, or maybe you intended to add the modifiers to the bottom of the stack - in that case uncomment the /../ chunks in the code below to make it work on baseobject instead.
Also, inverting the bitarray is as simple as setting its length and putting a minus sign in front of it.
(
local theObj = selection[1]
local theMesh = theObj.mesh
local theMod = Mesh_Select()
local selArray = #{3..4}
selArray.count = theMesh./*baseObject.*/numFaces
delete theMesh
addModifier theObj theMod /*before:theObj.modifiers.count*/
setFaceSelection theObj theMod (-selArray)
max modify mode
/*modPanel.setCurrentObject theMod*/
subObjectLevel = 3
modPanel.addModToSelection (DeleteMesh())
)