Tagging (sub)meshes for separate top level objects

I have a 3D mesh generated from a .geo file with two TopLevelObjects. These are to be assigned different materials. Basically, something like


solid p1=plane (0,0,0;0,0,-1);
solid p2=plane (1,1,1;0,0,1);
solid p3=plane (0,0,0;0,-1,0);
solid p4=plane (1,1,1;0,1,0);
solid p5=plane (0,0,0;-1,0,0);
solid p6=plane (1,1,1;1,0,0);

solid cube=p1 and p2 and p3 and p4 and p5 and p6;
solid sph = sphere(0.5, 0.5, 0.5; 0.1);
solid matrix=cube and not sph;
solid part = cube and sph
tlo matrix -transparent;
tlo parts -col=[1,0,0];
identify periodic p1 p2;
identify periodic p3 p4;
identify periodic p5 p6;
I generate the mesh as follows:

from netgen.csg import *
from ngsolve import *
geo = CSGeometry("Cube_Sphere.geo")
msh = geo.GenerateMesh(maxh=0.05)
msh.Export("AbaqusMesh.inp", "Abaqus Format") #this creates separate 'parts'
msh.Export("Gmsh_mesh.msh", "Gmsh2 Format") #this does not create separate physical tags

Is it possible to extract the corresponding meshes for each “TopLevelObject” (namely parts and matrix) and assign them physical tags them before exporting to gmsh. I need to eventually export the mesh in dolfin xdmf format. Since that is not naively supported, I want to export the mesh to gmsh-format and then manually convert it to dolfin xdmf (using meshio).

Thanks in advance!

not sure, but I think, every volume domain (toplevelobject) corresponds to a physical group in the gmsh mesh afterwards. The index is 100000+element index in Netgen.
Note Netgen does only support exporting to an old gmsh v2 file format. Maybe that is the problem?

Thanks for your reply Christopher. I would try to manually write the gmsh file and see.