You only need to create a temporary group and explode it after adding surface 2 and again for surface 3 as I demonstrated in my last code example.
It seems that the temporary group is still needed even when reading input from file as demonstrated by the following code and Gif.
mod = Sketchup.active_model
ent = mod.active_entities
sel = mod.selection
SKETCHUP_CONSOLE.clear
data_input=File.open('c:/users/public/sketchup/test/test.txt')
while !data_input.eof?
case data_input.readline.strip
when "BlockBegin Corner section"
corner = []
data = data_input.readline.strip
begin
typ,num,x,y,z=data.split(" ")
corner[num.to_i] = [x.to_f,y.to_f,z.to_f]
data = data_input.readline.strip
end until data.split(" ")[0]=="BlockEnd"
when "BlockBegin Surface section"
begin
sur,num,cnt = data_input.readline.strip.split(" ")
if sur == "LSurf"
if cnt.to_i > 1
for i in 0...cnt.to_i
p1,p2,p3,p4 = data_input.readline.strip.split(" ")
fac = ent.add_face(corner[p1.to_i],corner[p2.to_i],corner[p3.to_i],corner[p4.to_i])
fac.erase! if i > 0
end
else
p1,p2,p3,p4 = data_input.readline.strip.split(" "); grp = ent.add_group
fac = grp.entities.add_face(corner[p1.to_i],corner[p2.to_i],corner[p3.to_i],corner[p4.to_i])
grp.explode;
end
end
end while sur=="LSurf"
end
end
data_input.close
