Here's one way.
I'm going to use the contourRegionPlot3D
function from here. I include the function definition here for convenience:
contourRegionPlot3D[region_, {x_, x0_, x1_}, {y_, y0_, y1_}, {z_, z0_, z1_},
opts : OptionsPattern[]] := Module[{reg, preds},
reg = LogicalExpand[region && x0 <= x <= x1 && y0 <= y <= y1 && z0 <= z <= z1];
preds = Union@Cases[reg, _Greater | _GreaterEqual | _Less | _LessEqual, -1];
Show @ Table[ContourPlot3D[
Evaluate[Equal @@ p], {x, x0, x1}, {y, y0, y1}, {z, z0, z1},
RegionFunction -> Function @@ {{x, y, z}, Refine[reg, p] && Refine[! reg, ! p]},
opts], {p, preds}]]
Now create a region from the Graphics3D
objects:
c1 = Cuboid[{0, 0, 0}, {20, 2, 20}];
c2 = Cuboid[{12, 0, 8}, {17, 2, 17}];
c3 = Cylinder[{{5, -1, 10}, {5, 2, 10}}, 3];
reg = Fold[RegionDifference, c1, {c2, c3}];
Use RegionMember
to turn this into inequalities:
ineqs = Rest @ RegionMember[reg, {x, y, z}]
0 <= x <= 20 && 0 <= y <= 2 && 0 <= z <= 20 && ! (12 <= x <= 17 && 0
<= y <= 2 && 8 <= z <= 17) && ! (0 <= (1 + y)/3 <= 1 && (-5 + x)^2 + (-10 + z)^2 <= 9)
And then:
contourRegionPlot3D[ineqs, {x, 0, 20}, {y, 0, 2}, {z, 0, 20},
Mesh -> None, BoxRatios -> Automatic, PlotRange -> All, Boxed -> False, Axes -> False]
cub1 = Cuboid[{0, 0, 0}, {20, 2, 20}]; cub2 = Cuboid[{12, 0, 8}, {17, 2, 17}]; r2 = RegionDifference[cub1, cub2]; RegionPlot3D[r2]
!Mathematica graphics but the edges need some work. Original question at community.wolfram.com/groups/-/m/t/430092?p_p_auth=EAP2rQun $\endgroup$