I met stupid problems playing with combinations of simple 3D regions. Can anyboby explain what is wrong in my code?
I need to make a model for 3D-printing.
RegionPlot3D[{
Cuboid[{-3, -27, 0}, {-6, -50, 25}],
Cuboid[{-5, -41, 0}, {-20, -38, 25}],
Prism[{{-27, -38, 0}, {-19, -38, 0}, {-19, -45, 0}, {-27, -38,
25}, {-19, -38, 25}, {-19, -45, 25}}],
rg1,
Cuboid[{-3, 27, 0}, {-6, 50, 25}],
Cuboid[{-5, 41, 0}, {-20, 38, 25}],
Prism[{{-27, 38, 0}, {-19, 38, 0}, {-19, 45, 0}, {-27, 38,
25}, {-19, 38, 25}, {-19, 45, 25}}]},
PlotPoints -> 81,
Axes -> True, AxesLabel -> {"X", "Y", "Z"},
PlotRange -> {{-60, 60}, {-60, 60}, {0, 27}}]
where the rg1
is 3D-arc:
rg1=RegionIntersection[
RegionDifference[
Cylinder[{{0, 0, 0}, {0, 0, 25}}, 30],
Cylinder[{{0, 0, 0}, {0, 0, 25}}, 27]],
Cuboid[{-6, -30, 0}, {30, 30, 25}]
];
Generally, it looks like following:
However, I need the joint region to make the stl-file. Thus, I've tried the RegionUnion
to combine the elements. However, it is not so easy:
Making the clamps, I found that simple
RegionUnion[
Cuboid[{-3, -27, 0}, {-6, -50, 25}],
Cuboid[{-5, -41, 0}, {-20, -38, 25}],
Prism[{{-27, -38, 0}, {-19, -38, 0}, {-19, -45,
0}, {-27, -38, 25}, {-19, -38, 25}, {-19, -45, 25}}]
]
produces an error-message:
RegionBounds::reg: Cuboid[{-3,-27,0},{-6,-50,25}] is not a correctly specified region.
Ok, I've tried following:
rc1=RegionUnion[
Region@Cuboid[{-3, -27, 0}, {-6, -50, 25}],
Region@Cuboid[{-5, -41, 0}, {-20, -38, 25}],
Region@Prism[{{-27, -38, 0}, {-19, -38, 0}, {-19, -45,
0}, {-27, -38, 25}, {-19, -38, 25}, {-19, -45, 25}}]
];
rc2 = RegionUnion[
Region@Cuboid[{-3, 27, 0}, {-6, 50, 25}],
Region@Cuboid[{-5, 41, 0}, {-20, 38, 25}],
Region@
Prism[{{-27, 38, 0}, {-19, 38, 0}, {-19, 45, 0}, {-27, 38, 25}, {-19, 38, 25}, {-19, 45, 25}}]
];
It works good, making the separate clamps like following without errors:
But when I try to combine the whole model I again met the errors:
RegionPlot3D[{rg1, rc1, rc2}]
RegionPlot3D::nnregion: Region[BooleanRegion[#1||#2||#3&,{Cuboid[{-3,-27,0},{-6,-50,25}],Cuboid[{-5,-41,0},{-20,-38,25}],Prism[{{-27,-38,0},{-19,-38,0},{-19,-45,0},{-27,-38,25},{-19,-38,25},{-19,-45,25}}]}]] cannot be automatically discretized.
RegionPlot3D::invplotreg: {BooleanRegion[#1&&!#2&&,{Cylinder[{{0,0,0},{0,0,25}},30],Cylinder[{{0,0,0},{0,0,25}},27],Cuboid[{-6,-30,0},{30,30,25}]}],Region[BooleanRegion[#1||#2||#3&,{<<1>>}]],Region[BooleanRegion[#1||#2||#3&,{Cuboid[{-3,27,0},{-6,50,25}],Cuboid[{-5,41,0},{-20,38,25}],Prism[{{-27,38,0},{-19,38,0},{-19,45,0},{-27,38,25},{-19,38,25},{-19,45,25}}]}]]} is not a valid region to plot.
RegionPlot3D::argr: RegionPlot3D called with 1 argument; 4 arguments are expected.
When I try the RegionUnion[rc1,rg1,rc2]
, it gives me following:
Region[
BooleanRegion[Or[#, #2, #3,
And[#4,
Not[#5], #6], #7, #8, #9]& , {
Cuboid[{-3, -27, 0}, {-6, -50, 25}],
Cuboid[{-5, -41, 0}, {-20, -38, 25}],
Prism[{{-27, -38, 0}, {-19, -38, 0}, {-19, -45, 0}, {-27, -38,
25}, {-19, -38, 25}, {-19, -45, 25}}],
Cylinder[{{0, 0, 0}, {0, 0, 25}}, 30],
Cylinder[{{0, 0, 0}, {0, 0, 25}}, 27],
Cuboid[{-6, -30, 0}, {30, 30, 25}],
Cuboid[{-3, 27, 0}, {-6, 50, 25}],
Cuboid[{-5, 41, 0}, {-20, 38, 25}],
Prism[{{-27, 38, 0}, {-19, 38, 0}, {-19, 45, 0}, {-27, 38, 25}, {-19,
38, 25}, {-19, 45, 25}}]}]]
but it does not produce a normal 3D-region.
What is wrong with these 3D primitives?
RegionUnion[{Cuboid[{0, 0, 0}, {1, 1, 1}], Cuboid[{0, 0, 1}, {1, 1, 2}]}]
didn't work, you'd squash them together like thisRegionUnion[{Cuboid[{0, 0, 0}, {1, 1, 1}], Cuboid[{0, 0, 0.9999}, {1, 1, 2}]}]
By the way your first bit of code for the clamp worked for me on v12.1.1.0 and I got a correct lookingPolyhedron
object back, so you're probably experiencing a bug in an older version. . $\endgroup$