discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cross section views

DV
david vanhorn
Sat, Jan 3, 2026 9:21 PM

I am working on a project, the most complex thing I've done in OpenSCAD,
and I need cross section views so I can be sure the parts fit
appropriately.

I've tried using a difference with a box to do this job, but it gives very
odd results:

CubeSize=500;

module HalfClip(){
translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part.
cube(size = [CubeSize,CubeSize,CubeSize], center = true);
}// end of translate
}// end of module

module HandleBackBuck(){
$fn=180;
union(){
cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius);
translate([0,0,HandleHigh]){
Torus((HandleRadius-3),3);
}// end of translate
}// end of union
}// end of module

// This is the module called by the main file
module HandleBack(){
$fn=360;
color([0,1,1])
difference(){
HandleBackBuck();
translate([0,0,-1]){
cylinder( h=HandleHigh+2, d=(WireDia-0.2));
}
}// end of difference
}// end of module

// Slice it in half so we can see
module ShowHandleBack(){
difference(){
HandleBack();
#HalfClip();
}// end of difference
}// end of module

ShowHandleBack();
//HandleBack(); // For printing

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

Is there a better way?  I'm used to using clipping planes as in Povray, an
infinite plane which preserves everything on one side and discards
everything on the other side.  The "size" of the plane is therefore always
correct for the object being clipped.

--
K1FZY (WA4TPW) SK  9/29/37-4/13/15

I am working on a project, the most complex thing I've done in OpenSCAD, and I need cross section views so I can be sure the parts fit appropriately. I've tried using a difference with a box to do this job, but it gives very odd results: CubeSize=500; module HalfClip(){ translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part. cube(size = [CubeSize,CubeSize,CubeSize], center = true); }// end of translate }// end of module module HandleBackBuck(){ $fn=180; union(){ cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius); translate([0,0,HandleHigh]){ Torus((HandleRadius-3),3); }// end of translate }// end of union }// end of module // This is the module called by the main file module HandleBack(){ $fn=360; color([0,1,1]) difference(){ HandleBackBuck(); translate([0,0,-1]){ cylinder( h=HandleHigh+2, d=(WireDia-0.2)); } }// end of difference }// end of module // Slice it in half so we can see module ShowHandleBack(){ difference(){ HandleBack(); #HalfClip(); }// end of difference }// end of module ShowHandleBack(); //HandleBack(); // For printing As the attached pic shows, only some of the part is clipped, and this changes as you rotate the view! Is there a better way? I'm used to using clipping planes as in Povray, an infinite plane which preserves everything on one side and discards everything on the other side. The "size" of the plane is therefore always correct for the object being clipped. -- K1FZY (WA4TPW) SK 9/29/37-4/13/15
JB
Jon Bondy
Sat, Jan 3, 2026 9:35 PM

Your code does not compile, so it is hard to help.

Jon

On 1/3/2026 4:21 PM, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in
OpenSCAD, and I need cross section views so I can be sure the parts
fit appropriately.

I've tried using a difference with a box to do this job, but it gives
very odd results:

CubeSize=500;

module HalfClip(){
    translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the
part.
        cube(size = [CubeSize,CubeSize,CubeSize], center = true);
    }// end of translate
}// end of module

module HandleBackBuck(){
    $fn=180;
    union(){
cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius);
        translate([0,0,HandleHigh]){
            Torus((HandleRadius-3),3);
        }// end of translate
    }// end of union
}// end of module

// This is the module called by the main file
module HandleBack(){
    $fn=360;
    color([0,1,1])
    difference(){
        HandleBackBuck();
        translate([0,0,-1]){
            cylinder( h=HandleHigh+2, d=(WireDia-0.2));
        }
    }// end of difference
}// end of module

// Slice it in half so we can see
module ShowHandleBack(){
    difference(){
        HandleBack();
        #HalfClip();
    }// end of difference
}// end of module

ShowHandleBack();
//HandleBack(); // For printing

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

Is there a better way?  I'm used to using clipping planes as in
Povray, an infinite plane which preserves everything on one side and
discards everything on the other side.  The "size" of the plane is
therefore always correct for the object being clipped.

--
K1FZY (WA4TPW) SK  9/29/37-4/13/15


OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Your code does not compile, so it is hard to help. Jon On 1/3/2026 4:21 PM, david vanhorn via Discuss wrote: > I am working on a project, the most complex thing I've done in > OpenSCAD, and I need cross section views so I can be sure the parts > fit appropriately. > > I've tried using a difference with a box to do this job, but it gives > very odd results: > > CubeSize=500; > > module HalfClip(){ >     translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the > part. >         cube(size = [CubeSize,CubeSize,CubeSize], center = true); >     }// end of translate > }// end of module > > module HandleBackBuck(){ >     $fn=180; >     union(){ > cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius); >         translate([0,0,HandleHigh]){ >             Torus((HandleRadius-3),3); >         }// end of translate >     }// end of union > }// end of module > > // This is the module called by the main file > module HandleBack(){ >     $fn=360; >     color([0,1,1]) >     difference(){ >         HandleBackBuck(); >         translate([0,0,-1]){ >             cylinder( h=HandleHigh+2, d=(WireDia-0.2)); >         } >     }// end of difference > }// end of module > > > // Slice it in half so we can see > module ShowHandleBack(){ >     difference(){ >         HandleBack(); >         #HalfClip(); >     }// end of difference > }// end of module > > ShowHandleBack(); > //HandleBack(); // For printing > > As the attached pic shows, only some of the part is clipped, and this > changes as you rotate the view! > > Is there a better way?  I'm used to using clipping planes as in > Povray, an infinite plane which preserves everything on one side and > discards everything on the other side.  The "size" of the plane is > therefore always correct for the object being clipped. > > > -- > K1FZY (WA4TPW) SK  9/29/37-4/13/15 > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
CC
Cory Cross
Sat, Jan 3, 2026 9:55 PM

On 1/3/26 1:21 PM, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in
OpenSCAD, and I need cross section views so I can be sure the parts
fit appropriately.

Try with BOSL2's back_half and friends:
https://github.com/BelfrySCAD/BOSL2/wiki/partitions.scad#functionmodule-back_half

and see if those help.

Also, you'll want to Render and not Preview.
-Cory

On 1/3/26 1:21 PM, david vanhorn via Discuss wrote: > I am working on a project, the most complex thing I've done in > OpenSCAD, and I need cross section views so I can be sure the parts > fit appropriately. Try with BOSL2's back_half and friends: https://github.com/BelfrySCAD/BOSL2/wiki/partitions.scad#functionmodule-back_half and see if those help. Also, you'll want to Render and not Preview. -Cory
AM
Adrian Mariano
Sat, Jan 3, 2026 10:06 PM

If you want projections I would think that projection() might do the job,
with cut=true, probably.

On Sat, Jan 3, 2026 at 4:56 PM Cory Cross via Discuss <
discuss@lists.openscad.org> wrote:

On 1/3/26 1:21 PM, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in
OpenSCAD, and I need cross section views so I can be sure the parts
fit appropriately.

Try with BOSL2's back_half and friends:

https://github.com/BelfrySCAD/BOSL2/wiki/partitions.scad#functionmodule-back_half

and see if those help.

Also, you'll want to Render and not Preview.
-Cory


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If you want projections I would think that projection() might do the job, with cut=true, probably. On Sat, Jan 3, 2026 at 4:56 PM Cory Cross via Discuss < discuss@lists.openscad.org> wrote: > On 1/3/26 1:21 PM, david vanhorn via Discuss wrote: > > I am working on a project, the most complex thing I've done in > > OpenSCAD, and I need cross section views so I can be sure the parts > > fit appropriately. > > Try with BOSL2's back_half and friends: > > https://github.com/BelfrySCAD/BOSL2/wiki/partitions.scad#functionmodule-back_half > > and see if those help. > > Also, you'll want to Render and not Preview. > -Cory > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sat, Jan 3, 2026 11:37 PM

On 1/3/2026 1:21 PM, david vanhorn via Discuss wrote:

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_does_difference_(or_intersection)_sometimes_not_work_in_preview?

Keep the camera outside the model, and in particular outside the
invisible parts.

On 1/3/2026 1:21 PM, david vanhorn via Discuss wrote: > As the attached pic shows, only some of the part is clipped, and this > changes as you rotate the view! https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_does_difference_(or_intersection)_sometimes_not_work_in_preview? Keep the camera outside the model, and in particular outside the invisible parts.
GH
gene heskett
Sat, Jan 3, 2026 11:40 PM

On 1/3/26 16:25, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in OpenSCAD,
and I need cross section views so I can be sure the parts fit
appropriately.

I've tried using a difference with a box to do this job, but it gives very
odd results:

CubeSize=500;

module HalfClip(){
translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part.
cube(size = [CubeSize,CubeSize,CubeSize], center = true);
}// end of translate
}// end of module

module HandleBackBuck(){
$fn=180;
union(){
cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius);
translate([0,0,HandleHigh]){
Torus((HandleRadius-3),3);
}// end of translate
}// end of union
}// end of module

// This is the module called by the main file
module HandleBack(){
$fn=360;
color([0,1,1])
difference(){
HandleBackBuck();
translate([0,0,-1]){
cylinder( h=HandleHigh+2, d=(WireDia-0.2));
}
}// end of difference
}// end of module

// Slice it in half so we can see
module ShowHandleBack(){
difference(){
HandleBack();
#HalfClip();
}// end of difference
}// end of module

ShowHandleBack();
//HandleBack(); // For printing

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

We cannot load and test this, lots of missing variables.

Is there a better way?  I'm used to using clipping planes as in Povray, an
infinite plane which preserves everything on one side and discards
everything on the other side.  The "size" of the plane is therefore always
correct for the object being clipped.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Cheers, Gene Heskett, CET.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
    Don't poison our oceans, interdict drugs at the src.
On 1/3/26 16:25, david vanhorn via Discuss wrote: > I am working on a project, the most complex thing I've done in OpenSCAD, > and I need cross section views so I can be sure the parts fit > appropriately. > > I've tried using a difference with a box to do this job, but it gives very > odd results: > > CubeSize=500; > > module HalfClip(){ > translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part. > cube(size = [CubeSize,CubeSize,CubeSize], center = true); > }// end of translate > }// end of module > > module HandleBackBuck(){ > $fn=180; > union(){ > cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius); > translate([0,0,HandleHigh]){ > Torus((HandleRadius-3),3); > }// end of translate > }// end of union > }// end of module > > // This is the module called by the main file > module HandleBack(){ > $fn=360; > color([0,1,1]) > difference(){ > HandleBackBuck(); > translate([0,0,-1]){ > cylinder( h=HandleHigh+2, d=(WireDia-0.2)); > } > }// end of difference > }// end of module > > > // Slice it in half so we can see > module ShowHandleBack(){ > difference(){ > HandleBack(); > #HalfClip(); > }// end of difference > }// end of module > > ShowHandleBack(); > //HandleBack(); // For printing > > As the attached pic shows, only some of the part is clipped, and this > changes as you rotate the view! We cannot load and test this, lots of missing variables. > Is there a better way? I'm used to using clipping planes as in Povray, an > infinite plane which preserves everything on one side and discards > everything on the other side. The "size" of the plane is therefore always > correct for the object being clipped. > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org Cheers, Gene Heskett, CET. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Don't poison our oceans, interdict drugs at the src.
BC
Bob Carlson
Sun, Jan 4, 2026 12:43 AM

I have this built into my standard starting point files. I can always create a cross section thru the customizer.

-Bob

!start.root.0.scad:

fullResolution = true;

include <BClib/common.4.scad>
include <!start.0.scad>

showPart = 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();
}
}

And !start.0.scad:

module assembly() {
if (showPart) {
sphere(50);
}
}

And here is crossSection() 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);
}

}

On Jan 3, 2026, at 16:40, gene heskett via Discuss discuss@lists.openscad.org wrote:

On 1/3/26 16:25, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in OpenSCAD,
and I need cross section views so I can be sure the parts fit
appropriately.

I've tried using a difference with a box to do this job, but it gives very
odd results:

CubeSize=500;

module HalfClip(){
translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part.
cube(size = [CubeSize,CubeSize,CubeSize], center = true);
}// end of translate
}// end of module

module HandleBackBuck(){
$fn=180;
union(){
cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius);
translate([0,0,HandleHigh]){
Torus((HandleRadius-3),3);
}// end of translate
}// end of union
}// end of module

// This is the module called by the main file
module HandleBack(){
$fn=360;
color([0,1,1])
difference(){
HandleBackBuck();
translate([0,0,-1]){
cylinder( h=HandleHigh+2, d=(WireDia-0.2));
}
}// end of difference
}// end of module

// Slice it in half so we can see
module ShowHandleBack(){
difference(){
HandleBack();
#HalfClip();
}// end of difference
}// end of module

ShowHandleBack();
//HandleBack(); // For printing

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

We cannot load and test this, lots of missing variables.

Is there a better way?  I'm used to using clipping planes as in Povray, an
infinite plane which preserves everything on one side and discards
everything on the other side.  The "size" of the plane is therefore always
correct for the object being clipped.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Cheers, Gene Heskett, CET.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
    Don't poison our oceans, interdict drugs at the src.

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I have this built into my standard starting point files. I can always create a cross section thru the customizer. -Bob !start.root.0.scad: fullResolution = true; include <BClib/common.4.scad> include <!start.0.scad> showPart = 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(); } } And !start.0.scad: module assembly() { if (showPart) { sphere(50); } } And here is crossSection() 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); } } > On Jan 3, 2026, at 16:40, gene heskett via Discuss <discuss@lists.openscad.org> wrote: > > On 1/3/26 16:25, david vanhorn via Discuss wrote: >> I am working on a project, the most complex thing I've done in OpenSCAD, >> and I need cross section views so I can be sure the parts fit >> appropriately. >> >> I've tried using a difference with a box to do this job, but it gives very >> odd results: >> >> CubeSize=500; >> >> module HalfClip(){ >> translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part. >> cube(size = [CubeSize,CubeSize,CubeSize], center = true); >> }// end of translate >> }// end of module >> >> module HandleBackBuck(){ >> $fn=180; >> union(){ >> cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius); >> translate([0,0,HandleHigh]){ >> Torus((HandleRadius-3),3); >> }// end of translate >> }// end of union >> }// end of module >> >> // This is the module called by the main file >> module HandleBack(){ >> $fn=360; >> color([0,1,1]) >> difference(){ >> HandleBackBuck(); >> translate([0,0,-1]){ >> cylinder( h=HandleHigh+2, d=(WireDia-0.2)); >> } >> }// end of difference >> }// end of module >> >> >> // Slice it in half so we can see >> module ShowHandleBack(){ >> difference(){ >> HandleBack(); >> #HalfClip(); >> }// end of difference >> }// end of module >> >> ShowHandleBack(); >> //HandleBack(); // For printing >> >> As the attached pic shows, only some of the part is clipped, and this >> changes as you rotate the view! > We cannot load and test this, lots of missing variables. >> Is there a better way? I'm used to using clipping planes as in Povray, an >> infinite plane which preserves everything on one side and discards >> everything on the other side. The "size" of the plane is therefore always >> correct for the object being clipped. >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > Cheers, Gene Heskett, CET. > -- > "There are four boxes to be used in defense of liberty: > soap, ballot, jury, and ammo. Please use in that order." > -Ed Howdershelt (Author, 1940) > If we desire respect for the law, we must first make the law respectable. > - Louis D. Brandeis > Don't poison our oceans, interdict drugs at the src. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
BC
Bob Carlson
Sun, Jan 4, 2026 12:47 AM

You need moveSP from my lib too.

/*
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 Jan 3, 2026, at 17:43, Bob Carlson bob@rjcarlson.com wrote:

I have this built into my standard starting point files. I can always create a cross section thru the customizer.

-Bob

!start.root.0.scad:

fullResolution = true;

include <BClib/common.4.scad>
include <!start.0.scad>

showPart = 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();
}
}

And !start.0.scad:

module assembly() {
if (showPart) {
sphere(50);
}
}

And here is crossSection() 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);
 }

}

On Jan 3, 2026, at 16:40, gene heskett via Discuss discuss@lists.openscad.org wrote:

On 1/3/26 16:25, david vanhorn via Discuss wrote:

I am working on a project, the most complex thing I've done in OpenSCAD,
and I need cross section views so I can be sure the parts fit
appropriately.

I've tried using a difference with a box to do this job, but it gives very
odd results:

CubeSize=500;

module HalfClip(){
translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part.
cube(size = [CubeSize,CubeSize,CubeSize], center = true);
}// end of translate
}// end of module

module HandleBackBuck(){
$fn=180;
union(){
cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius);
translate([0,0,HandleHigh]){
Torus((HandleRadius-3),3);
}// end of translate
}// end of union
}// end of module

// This is the module called by the main file
module HandleBack(){
$fn=360;
color([0,1,1])
difference(){
HandleBackBuck();
translate([0,0,-1]){
cylinder( h=HandleHigh+2, d=(WireDia-0.2));
}
}// end of difference
}// end of module

// Slice it in half so we can see
module ShowHandleBack(){
difference(){
HandleBack();
#HalfClip();
}// end of difference
}// end of module

ShowHandleBack();
//HandleBack(); // For printing

As the attached pic shows, only some of the part is clipped, and this
changes as you rotate the view!

We cannot load and test this, lots of missing variables.

Is there a better way?  I'm used to using clipping planes as in Povray, an
infinite plane which preserves everything on one side and discards
everything on the other side.  The "size" of the plane is therefore always
correct for the object being clipped.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Cheers, Gene Heskett, CET.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
    Don't poison our oceans, interdict drugs at the src.

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You need moveSP from my lib too. /* 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 Jan 3, 2026, at 17:43, Bob Carlson <bob@rjcarlson.com> wrote: > > I have this built into my standard starting point files. I can always create a cross section thru the customizer. > > -Bob > > !start.root.0.scad: > > fullResolution = true; > > include <BClib/common.4.scad> > include <!start.0.scad> > > showPart = 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(); > } > } > > And !start.0.scad: > > module assembly() { > if (showPart) { > sphere(50); > } > } > > And here is crossSection() 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); > } > } > > >> On Jan 3, 2026, at 16:40, gene heskett via Discuss <discuss@lists.openscad.org> wrote: >> >> On 1/3/26 16:25, david vanhorn via Discuss wrote: >>> I am working on a project, the most complex thing I've done in OpenSCAD, >>> and I need cross section views so I can be sure the parts fit >>> appropriately. >>> >>> I've tried using a difference with a box to do this job, but it gives very >>> odd results: >>> >>> CubeSize=500; >>> >>> module HalfClip(){ >>> translate([CubeSize/2,0,0]){ // this puts one face at 0,0,0 of the part. >>> cube(size = [CubeSize,CubeSize,CubeSize], center = true); >>> }// end of translate >>> }// end of module >>> >>> module HandleBackBuck(){ >>> $fn=180; >>> union(){ >>> cylinder(h=HandleHigh,r1=HandleRadiusTop,r2=HandleRadius); >>> translate([0,0,HandleHigh]){ >>> Torus((HandleRadius-3),3); >>> }// end of translate >>> }// end of union >>> }// end of module >>> >>> // This is the module called by the main file >>> module HandleBack(){ >>> $fn=360; >>> color([0,1,1]) >>> difference(){ >>> HandleBackBuck(); >>> translate([0,0,-1]){ >>> cylinder( h=HandleHigh+2, d=(WireDia-0.2)); >>> } >>> }// end of difference >>> }// end of module >>> >>> >>> // Slice it in half so we can see >>> module ShowHandleBack(){ >>> difference(){ >>> HandleBack(); >>> #HalfClip(); >>> }// end of difference >>> }// end of module >>> >>> ShowHandleBack(); >>> //HandleBack(); // For printing >>> >>> As the attached pic shows, only some of the part is clipped, and this >>> changes as you rotate the view! >> We cannot load and test this, lots of missing variables. >>> Is there a better way? I'm used to using clipping planes as in Povray, an >>> infinite plane which preserves everything on one side and discards >>> everything on the other side. The "size" of the plane is therefore always >>> correct for the object being clipped. >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> Cheers, Gene Heskett, CET. >> -- >> "There are four boxes to be used in defense of liberty: >> soap, ballot, jury, and ammo. Please use in that order." >> -Ed Howdershelt (Author, 1940) >> If we desire respect for the law, we must first make the law respectable. >> - Louis D. Brandeis >> Don't poison our oceans, interdict drugs at the src. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >