Is it possible to use RegionFunction with Graphics3D?

I am using Graphics3D and I would like to use RegionFunction to exclude specific regions as in Plot3D but I could not. Here is my code:

ax := 0; az := 1; ay := 0
unitCell3D[x_, y_, z_] := {Black, Sphere[{x + ax, y + ay, az}, 0.13],
Black, Sphere[{x + ax, y + ay + 2/3 Sin[120 Degree], az}, 0.13],
Gray, Cylinder[{{x + ax, y + ay, az}, {x + ax,
y + ay + 2/3 Sin[120 Degree], az}}, 0.02],
Cylinder[{{x + ax, y + ay, az}, {x + ax + Cos[30 Degree]/2,
y + ay - Sin[30 Degree]/2, az}}, 0.02],
Cylinder[{{x + ax, y + ay, az}, {x + ax - Cos[30 Degree]/2,
y + ay - Sin[30 Degree]/2, az}}, 0.02]}

f2 = Graphics3D[
Block[{unitVectA = {Cos[120 Degree], Sin[120 Degree], 0},
unitVectB = {1, 0, 0}},
Table[unitCell3D @@ (unitVectA j + unitVectB k), {j, 20}, {k,
20}]], PlotRange -> {{-0.1, 7.128}, {1.3, 8.0}, {-0.3, 1.3}},
Boxed -> False, Axes -> False]
p2 = Plot3D[1, {x, -20, 20}, {y, -20, 20},
RegionFunction ->
Function[{x, y, z},
3 <= (x - (-0.1 + 7.128)/2)^2 + (y - (8 + 1.3)/2)^2 <= 50],
Axes -> None, MeshStyle -> None, PlotPoints -> 80,
PlotStyle ->
Directive[Red, Specularity[White, 10], Opacity[0.9],
Lighting -> "Neutral"], BoundaryStyle -> {Green, Thick, Dashed}]

Show[f2, p2, PlotRange -> {{-0.1, 7.128}, {1.3, 8.0}, {-0.3, 1.3}},
Boxed -> False, ViewPoint -> {3, -6, 3}]


inside the dashed-green circle is an excluded region in the Plot3D, but results from Graphis3D are showing within this excluded region. I tried to use RegionFunction in the Graphis3D but it did not work. I would like exclude this region in both figures, is that possible?

• The output of Plot3D and other 3D-rountines is a Graphics3D object. You can merge arbitrary Graphics3D objects with Show. – Henrik Schumacher Nov 5 at 15:08
• @Henrik Schumacher, when I combine them using Show, the excluded region in Plot3Dappears in the Graphics3D plot – HD2006 Nov 5 at 15:45
• Hm. Not when I try it. Please give an example, then we can see what might have gone wrong. – Henrik Schumacher Nov 5 at 16:53
• @Henrik Schumacher, well, I think I did not made the point clear. Simply, in the first fig with Hexagonal lattice, I would like to exclude a specific region (inside or outside a circle on the top one) as explained in the last two Figs. So the last two figures are just to imply what I would like to do with the first one. Combining them using Showwill not exclude the desired region in the hexagonal lattice plot – HD2006 Nov 5 at 17:12
• Ah. Then you should make that clear in the post itself, not only in a comment. – Henrik Schumacher Nov 5 at 17:31

Here is an approach using DiscretizeGraphics and RegionDifference to manually cut the affected objects:

hole=Cylinder[(* the object describing the hole to cut out *)
{
{(-0.1+7.128)/2,(8+1.3)/2,0},
{(-0.1+7.128)/2,(8+1.3)/2,2}},

];

dhole=DiscretizeRegion@hole(* discretized version of hole *);
f2/.
Sphere->Ball/.(* replace Sphere with Ball to ensure all the objects are solid *)
(* replace all regions that intersect with the hole *)
r_?(RegionQ@#&&!RegionDisjoint[hole,#]&):>
If[
RegionWithin[hole,r],(* if the region is fully contained, drop it *)
Nothing,
(* otherwise cut out the part intersecting the hole *)
{
EdgeForm@None,(* this ensures that the cell edges are not drawn *)
BoundaryMesh[(* we only care about the surface *)
RegionDifference[DiscretizeRegion@r,dhole](* discretize and cut away the hole *)
]
}
]


The objects at the boundary of the hole are properly handled: