discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Does this difference() work?

BL
Bryan Lee
Thu, Oct 22, 2020 6:36 AM

I am trying to use this openscad script, Updated 12-16-2013:
https://www.thingiverse.com/thing:188275/files

When I set Type=3 I do not get the outer spinning ring, but it DOES work
when Type=1.

Inside module spinner() we find a difference involving 4 if()'s:

difference()
	{
	if (Type==1)
		{
		cylinder(h=sw,r=sr,$fn=200);// flat
 		}
	if (Type==2)
		{
		union()
			{
			hbanded(sr,sw);// horizontal bands
			}
		}
	if (Type==3)
		{
		knurled_cyl(sw,kod,kw,kh,kd,kd,ks);
		}
	if (Type==4)
		{
		difference()
			{
			cylinder(h=sw,r=sr,$fn=200);// flat
			color([1,0,0])
			scale(font_scale)
			writecylinder(Message,[0,0,0],(sr/font_scale*1.01),sw+Font_Height,space=1.05+font_factor,rotate=0,font=Font,t=Font_Cut);
			}
		}

	translate([0,0,-1])cylinder(h=(Ring_Thickness),r=(ring_outer+1.5),$fn=200);
	}

I fixed it by putting a union() around the if()'s.

QUESTION:  I'm running openscad-nightly, so, version 2020.10.21.  In much older
versions would the multiple if()'s have worked correctly?

All the modules seem to work correctly, although the writecylinder() module
wants to use <write/Write.scad>

I am trying to use this openscad script, Updated 12-16-2013: https://www.thingiverse.com/thing:188275/files When I set Type=3 I do not get the outer spinning ring, but it DOES work when Type=1. Inside module spinner() we find a difference involving 4 if()'s: difference() { if (Type==1) { cylinder(h=sw,r=sr,$fn=200);// flat } if (Type==2) { union() { hbanded(sr,sw);// horizontal bands } } if (Type==3) { knurled_cyl(sw,kod,kw,kh,kd,kd,ks); } if (Type==4) { difference() { cylinder(h=sw,r=sr,$fn=200);// flat color([1,0,0]) scale(font_scale) writecylinder(Message,[0,0,0],(sr/font_scale*1.01),sw+Font_Height,space=1.05+font_factor,rotate=0,font=Font,t=Font_Cut); } } translate([0,0,-1])cylinder(h=(Ring_Thickness),r=(ring_outer+1.5),$fn=200); } I fixed it by putting a union() around the if()'s. QUESTION: I'm running openscad-nightly, so, version 2020.10.21. In much older versions would the multiple if()'s have worked correctly? All the modules seem to work correctly, although the writecylinder() module wants to use <write/Write.scad>
M
MichaelAtOz
Thu, Oct 22, 2020 6:54 AM

There is a difference with difference, discussion on GitHub, I haven't kept
up to date on whether it is a bug or change.

But if you want to fix it, put all the if's inside a union() {...}, with
this line outside/after the union (making it the second child of the diff.)
translate([0,0,-1])cylinder(h=(Ring_Thickness),r=(ring_outer+1.5),$fn=200);


OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

  • on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

There is a difference with difference, discussion on GitHub, I haven't kept up to date on whether it is a bug or change. But if you want to fix it, put all the if's inside a union() {...}, with this line outside/after the union (making it the second child of the diff.) translate([0,0,-1])cylinder(h=(Ring_Thickness),r=(ring_outer+1.5),$fn=200); ----- OpenSCAD Admin - email* me if you need anything, or if I've done something stupid... * on the Forum, click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. -- Sent from: http://forum.openscad.org/