Does OpenSCAD have a way to view a cross section of a model? I’m aware of the % (transparent) modifier, but I’m looking for a way to slice through a model on a given plane.
As I write this, I guess is would be possible to do a difference with a cuboid representing the cut-away part of the plane, but is there a better way?
Mark
If you're open to using BOSL2 library:
https://github.com/BelfrySCAD/BOSL2/wiki/partitions.scad
Dan
On Tue, Nov 19, 2024 at 1:57 PM Mark Erbaugh via Discuss <
discuss@lists.openscad.org> wrote:
Does OpenSCAD have a way to view a cross section of a model? I’m aware of
the % (transparent) modifier, but I’m looking for a way to slice through a
model on a given plane.
As I write this, I guess is would be possible to do a difference with a
cuboid representing the cut-away part of the plane, but is there a better
way?
Mark
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 11/19/2024 5:56 AM, Mark Erbaugh via Discuss wrote:
Does OpenSCAD have a way to view a cross section of a model? I’m aware of the % (transparent) modifier, but I’m looking for a way to slice through a model on a given plane.
As I write this, I guess is would be possible to do a difference with a cuboid representing the cut-away part of the plane, but is there a better way?
There is no cross-section view. You can use difference or intersection
to achieve the same effect.
Caution: in perspective mode, the previewer doesn't like it when the
camera is inside negative space for a difference. This is often a
problem when you're differencing away large cubes to do cut-aways. This
program demonstrates the problem:
difference() {
sphere(10);
cube(1000);
}
In perspective mode, rotate the view so that the camera is looking at
the sphere from the positive-XYZ octant; observe that the cut-away
portion is restored.
I thought there was a similar effect for intersection, but I'm not
duplicating it at the moment.
What about just moving the desired x-section to XY plane and use
projection(cut=true) on that ?
Jordan Brown via Discuss discuss@lists.openscad.org schrieb am Di., 19.
Nov. 2024, 17:01:
On 11/19/2024 5:56 AM, Mark Erbaugh via Discuss wrote:
Does OpenSCAD have a way to view a cross section of a model? I’m aware of the % (transparent) modifier, but I’m looking for a way to slice through a model on a given plane.
As I write this, I guess is would be possible to do a difference with a cuboid representing the cut-away part of the plane, but is there a better way?
There is no cross-section view. You can use difference or intersection to
achieve the same effect.
Caution: in perspective mode, the previewer doesn't like it when the
camera is inside negative space for a difference. This is often a problem
when you're differencing away large cubes to do cut-aways. This program
demonstrates the problem:
difference() {
sphere(10);
cube(1000);
}
In perspective mode, rotate the view so that the camera is looking at the
sphere from the positive-XYZ octant; observe that the cut-away portion is
restored.
I thought there was a similar effect for intersection, but I'm not
duplicating it at the moment.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 11/19/2024 8:07 AM, Guenther Sohler wrote:
What about just moving the desired x-section to XY plane and use
projection(cut=true) on that ?
Indeed, if what you want is a cross-section rather than a cut-away, that
will work. Loses color, unfortunately.
On Tue, Nov 19, 2024 at 08:56:43AM -0500, Mark Erbaugh via Discuss wrote:
As I write this, I guess is would be possible to do a difference
with a cuboid representing the cut-away part of the plane, but is
there a better way?
Yeah. That's what I always do.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a** is going up. -- Chris Hadfield about flying up the space shuttle.
** 'a' for accelleration.
This is my !start here.scad file. I now start every project with this construction. I can add a cross section in any part of my project in a few seconds. I use my own crossSection() module, but the BOSL2 equivalents could also be used with a little modification. My crossSection code is in my library, but I show it below. The include also includes BOSL2 so a single include from my lib is sufficient for most things. Obviously I add various calls to “assembly" as I build.
include <BClib/common.4.scad>
showX = false;
ex = 0;
doCrossSection = "none"; // ["none", "x", "y", "z", "-x", "-y", "-z", "polar"]
radius = 0;
phi = 0;
theta = 0;
module Customizer_Limit () {} // This actually works
CS();
module CS() {
if (doCrossSection == "none") {
d = echo("none");
assembly();
} else if (doCrossSection == "polar") {
d = echo("polar");
crossSection(r = radius, theta = theta, phi = phi)
assembly();
} else {
d = echo(doCrossSection);
crossSection(view = doCrossSection, r = radius)
assembly();
}
}
module assembly() {
if (showX) {
sphere(50);
}
}
From my library:
/*
crossSection(view = "x", r, theta, phi, right, fwd, up)
r - distance from origin
theta - angle of rotation in XY from +X counter clockwise
phi - Angle from +Z, 0 == straight up
*/
module crossSection(view = "", right = 0, fwd = 0, up = 0, r = 0, theta = -1000, phi = -1000) {
if (_Help(view)) {
echo("view - axis to view from, or alternately, to remove");
echo("r - distance from origin");
echo("theta - angle of rotation in XY from +X counter clockwise");
echo("phi - Angle from +Z, 0 == straight up");
}
//d = echo("crossSection ", view, r, theta, phi);
th = theta > -360 && theta < 360 ? theta
: view == "x" ? 0
: view == "y" ? 90
: view == "z" ? 0
: view == "-x" ? 180
: view == "-y" ? -90
: view == "-z" ? 0
: 0;
ph = phi >= 0 && phi <= 180 ? phi
: view == "x" ? 90
: view == "y" ? 90
: view == "z" ? 0
: view == "-x" ? 90
: view == "-y" ? 90
: view == "-z" ? 180
: 90;
m = r != 0 ? r
: right != 0 ? right
: fwd != 0 ? -fwd
: up != 0 ? up
: 0;
//d0 = echo("crossSection ", m, th, ph);
difference() {
union() {
children();
}
moveSP(r = m, theta = th, phi = ph)
zrot(th)
yrot(ph)
cube(1000, anchor = BOTTOM);
}
}
/*
moveSP(r, theta, phi)
Move Spherical
r - distance from origin
theta - angle of rotation in XY from +X couter clockwise
phi - Angle from +Z, 0 == straight up
*/
module moveSP(r, theta, phi) {
move(spherical_to_xyz(r, theta, phi)) children();
}
On Nov 19, 2024, at 06:56, Mark Erbaugh via Discuss discuss@lists.openscad.org wrote:
Does OpenSCAD have a way to view a cross section of a model? I’m aware of the % (transparent) modifier, but I’m looking for a way to slice through a model on a given plane.
As I write this, I guess is would be possible to do a difference with a cuboid representing the cut-away part of the plane, but is there a better way?
Mark
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org