[OpenSCAD] How can I make a phase on a cube just on on side

shadowwynd shadowwynd at gmail.com
Fri May 3 06:27:13 EDT 2019


You can't use minkowski()  this way.  By definition, it is impossible to get
an accurate "cube" with only one side rounded.

I normally use hull() to get a rounded "cubish" thing.  See the code and
example below.

----------------------

// Cube with rounded face

dim = [100, 50, 40];

corner_r = 10;
grain = 1;

// Top edges and corners rounded, but spills onto the sides
hull()
{
	// Define lower side of cube
	translate ([0, 0, 0]) cube (grain);
	translate ([dim.x - grain, 0, 0]) cube (grain);
	translate ([dim.x - grain, dim.y-grain, 0]) cube (grain);
	translate ([0, dim.y-grain, 0]) cube (grain);

	// Rounded face
	translate ([0+corner_r, 0+corner_r, dim.z-corner_r]) sphere (r=corner_r);
	translate ([dim.x-corner_r, 0+corner_r, dim.z-corner_r]) sphere
(r=corner_r);
	translate ([dim.x-corner_r, dim.y-corner_r, dim.z-corner_r]) sphere
(r=corner_r);
	translate ([0+corner_r, dim.y-corner_r, dim.z-corner_r]) sphere
(r=corner_r);

}

// Create a rounded cube, but a flat bottom
translate ([-dim.x-10, 0, 0])
{
	hull()
	{
		// Define lower side of cube
		linear_extrude(1)
		{
			
			translate ([0+corner_r, 0+corner_r, 0]) circle (r=corner_r);
			translate ([dim.x-corner_r, 0+corner_r, 0]) circle (r=corner_r);
			translate ([dim.x-corner_r, dim.y-corner_r, 0]) circle (r=corner_r);
			translate ([0+corner_r, dim.y-corner_r, 0]) circle (r=corner_r);
		}

		// Rounded top face
		translate ([0+corner_r, 0+corner_r, dim.z-corner_r]) sphere (r=corner_r);
		translate ([dim.x-corner_r, 0+corner_r, dim.z-corner_r]) sphere
(r=corner_r);
		translate ([dim.x-corner_r, dim.y-corner_r, dim.z-corner_r]) sphere
(r=corner_r);
		translate ([0+corner_r, dim.y-corner_r, dim.z-corner_r]) sphere
(r=corner_r);

	}
}

------------------

<http://forum.openscad.org/file/t486/roundedCube.png> 



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



More information about the Discuss mailing list