MakerBot Print is our newest print-prepration software, which supports native CAD files and STL assemblies,
allows you to interact with all your printers via the Cloud, and many other exciting new features.

I'm wanting to create a box that has an slope front at approx 130 degrees, and a sloped rear at 40 degrees. The box is to have walls that are 2mm thick.

The box currently is in two parts that form a union, the first part is a slim box that has a hollow middle, the walls are 2mm thick, and the x, y, z is [60, 40, 6]

I think there is two ways I can do the front and rear slopes, I'd like the total height of the box to be 20.

The first way could be to make an additonal box with the same dimensions as the lower box but with a height of 14 such as x, y, z of [60, 40, 14], translate would need to be used with this. Make additional cubes and rotate and translate them then use difference to remove the parts from the cube. The problem I am having with this method is lining everything up accurately it seems near impossible to line everything up pixel perfect, it also is very difficult to get the slopes to start at the same height on the front and rear.

So I thought of a different way I could make thin cubes of 2mm thick as I wanted walls that thick anyway, such as using x, y, z of [56, 2, 22] and then rotate and translate them, this has the added benefit of not needing to have anything cut out from the inside of the cube to make the walls 2mm thick. It however doesn't solve the problem of lining everything up accurately it still seems near impossible to line everything up pixel perfect.

Once I have been able to resolve the above issues I was wanting to cut a rectangle hole in the front slope, the rear slope won't have a hole cut into it.

If someone could potentially share their thoughts and ideas, or perhaps even give some recommendations as to what you think I should do to get the results I am after it would be very much appreciated, I wouldn't necessarily need the code writing for me as I do have a programming/scripting background, but that being said if you would like to share some rough examples to explain what your suggesting that would be very much appreciated.

Here's an example ... it's actually slightly different than my description because once you go 2D, you can make things even easier with the offset function.

(The cutting out of the inner empty space is deliberately displaced so that you can see it :-)

@Bikecyclist The example you made looks good, although the code looks a bit complex, I'm going to need a moment to figure that out for myself, I only found out about OpenSCAD today, someone on thingiverse said they use it for all their models (don't think they are in this group).

I've attached my first and second attempts to my original post, although it's now been flagged for moderation since I have done that.

Once you've wrapped your head around it (which I hope with the clockface example will be easy-ish), it often helps to solve those "pixel-positioning" problems pretty quickly.

The basic shape that you want seems to be a kind of a trapezoidal prism. I can think of two simple ways of defining something like this:
1) define two squares and build a hull around them
2) define points and build a polyhedron using them (example: https://github.com/dannystaple/OpenSCAD-Parts-Library/blob/master/prism.scad)

If you make it parametric, there should be no difficulty in creating a difference of the outer shape and another offset inside.

After you have the basic shape done, things like cutting a hole from one side etc are just minor technicalities. I hope this helps.

@svofski Thanks for your reply, I am unsure what you mean by build a hull around them. I have the two squares defined as that was my second idea attempt.

That prism code makes nice triangles, am not sure just how it is doing that however, but looks good I think I may possibly be able to use that.

"hull ()" is an OpenSCAD function. It's powerful, but if applied to 3D objects, it takes a lot of computing time.

Think of it as a rubber balloon stretched tightly over any number of 3D objects, enveloping them closely. That's the kind of shape you can create with "hull ()".

If you box had slopes on all four sides so you couldn't build it as a linear_extrusion of a 2D shape, hull () might be a good choice. It can deal with irregular shapes and is easy to apply, but you can end up with really long computing times ... take your pick.

(It also works on 2D objects, where it's really quick in comparison.)

Another option is to use my pointHull() library module: https://www.thingiverse.com/thing:3696364
Just feed it a list of the coordinates of the corners of the box (or any other convex shape), and it'll put a convex hull around them. No need to figure out the faces for feeding into polyhedron(), no unnecessary bumps from calling hull() with thin 3D slabs, etc.

I am also having trouble visualizing the box you want. Does it look anything like this?
This is just the outer box, and I have just used randomly chosen coordinates for the slope.
Just a starter.

@lar3ry Both are those are what I was after, I'm not sure I understand the difference between the two visually they look similar ish, but split into triangles on the second one.

I would want to 3D print the final result, how would I hollow out the middle? as I would want walls that are 2mm thick. I've attached a screenshot of my first attempt, I did try and add them to my initial post but it has been flagged for moderation since doing so.

Not sure what you mean by "split into triangles on the second one". The two boxes are different in that one has the slopes on the short dimension and the other has them on the long dimension. They are two separate objects.

The next order of business is to hollow out the box, as you say. In general, the way to do that is to make a smaller box, translate it into position, and use difference() to subtract it from the larger box.

In the attached file, there are three modules and the main program.

box_profile() is a 2D object that we can extrude. It is called twice from the module box_shell() to create the desired shape.

box_shell() creates a 3D object that looks like the box without the end walls. If you want to see what that looks like, place a ! in front of the call to box_shell() in the main program. This makes it show the shell only.

end_wall() makes an end wall, which we can rotate/translate into place in order to enclose the box.

The main program creates the hollow box by calling box_shell() once and end_wall() twice, translating the second wall to the far end. This is done within a union() which causes them to be combined wherever they overlap.

It then creates a cube to cut out the bottom of the box (because it looked like you wanted it open in your capture pic), and another cube, rotated and translated to cut out the front opening. Within the difference() statement, the object within the union has the two cubes subtracted from it.

You will notice that there is a # in front of the front opening cube statement. This makes it highlight when previewed (F5). Handy for showing parts in relation to each other. Render (F6) will show the result, with no highlighting.

All you have left to do is to adjust the points in the polygon, the angles of the slopes, and the various dimensions for the cubes.

Pardon the long windedness, but I though you might benefit from knowing the details of it.

@AeroMaxx I find it a bit difficult to express geometries verbally, how about this screenshot instead. Does it look remotely like something you have in mind?

@svofski I did try and add my files to my initial post, but it has been flaggerd for moderation, this seems to be a long process I was hoping it would have been done by now. I've added a screenshot hope this helps!

Your picture is sort of what I was after, but slopes only on two sides, and not at the same angle.

The shape consists of a hull between two planes, top side and base. The angles of the side slopes depends on the Y size of the top plane, and to adjust the angles just change TopSideYOffset. The hollowing is made scaling the original box down to a certain size. This will not give you the ability to select an exact wall size, just eyeballing...second thing is the slope wall is sligtly thinner near the bottom...
It may not be your solution, but adds ideas that can be worked on...
If you are going to print it, I will consider not hollowing it out, but making it solid and use a low infill because the top side of your print will need support anyway...

@AeroMaxx it really helps seeing the draft of what you're trying to get. It differs from what I sketched because there's also a vertical part on one side, which makes that bit also asymmetrical. There are numerous ways of doing that, but in this case I would just follow the intuition and actually start with a cube, then shave off the slopes from it using difference() with 2 other rotated and translated cubes. As if you were making it from a block of wood with a chisel.

The hole is another subtracted cube. You'll just have to figure out the rotations/translations. If you can't simply eyeball them, probably some maths with a sideways 2d projection on a piece of paper would help to figure out the angles and offset.

@svofski "I would just follow the intuition and actually start with a cube, then shave off the slopes from it using difference() with 2 other rotated and translated cubes."

You mentioned the above, in the picture that is exactly what I did.

"The hole is another subtracted cube."

Yes that's what I have done also to get where I currently am, but am unhappy with the results so far. The problem I am having is that the height the slope starts at is different on the front and rear, the slopes don't start at the same z value, and as mentioned it's extremely difficult to line everything up pixel perfect.

You mentioned some maths with a sideways 2d projection on a piece of paper you totally lost me here, I know what angles I would like the slopes to be at, but lining them up is a nightmare it seems.

I would also need to somehow hollow out the whole of the middle as I was intending to 3d print it, and was wanting 2mm thick walls for the inside.

@AeroMaxx if you know the angles of the slopes and where they start, there's no maths involved as such. You just need to put the chiseling cubes in their respective positions. For example:

eps=0.01;

tost(x=40,y=20,h=20,h1=2,h2=4,a1=15,a2=-10);

// width, depth, height, left vertical height, right vertical height
//
module tost(x,y,h,h1,h2,a1,a2)
{
Q=[33,33,33]; // chisel cube, should be le big

difference() {
cube([x,y,h]); // the big block
translate([0,-eps,-eps]) {
// right slanted edge
#translate([x,0,h2]) // move it so that its bottom-left corner is on the right wall of the cube, at height h2
rotate([0,a2,0]) // rotate it at a given angle
cube(Q);
// left slanted edge
#translate([0,0,h1]) // this one we translate at the given height h1
rotate([0,a1,0]) // and rotate it too
translate([-Q.x,0,0]) // but not before offsetting its position so that its right-bottom corner is at the origin (0,0)
cube(Q);
}
}

}

As for hollowing out, there were other examples in this thread already. The basic idea is to subtract a smaller copy of the same shape from the bigger copy of same. Alternatively, any slicer will do that if you set infill to zero.

With regard to hollowing it out, the "standard" method is to make the solid box a module in OpenSCAD to which you pass the size as a parameter, like "module solidbox (x, y, z)".

Then the main code looks like this:

wall = 2;
difference
{
solidbox (x, y, z);
solidbox (x - 2 * wall, y - 2 * wall, z - 2 * wall);
}

(You might need a "translate" before the second solidbox if you're not creating the solidbox centered on the origin, as I assumed.)

I'm wanting to create a box that has an slope front at approx 130 degrees, and a sloped rear at 40 degrees. The box is to have walls that are 2mm thick.

The box currently is in two parts that form a union, the first part is a slim box that has a hollow middle, the walls are 2mm thick, and the x, y, z is [60, 40, 6]

I think there is two ways I can do the front and rear slopes, I'd like the total height of the box to be 20.

The first way could be to make an additonal box with the same dimensions as the lower box but with a height of 14 such as x, y, z of [60, 40, 14], translate would need to be used with this. Make additional cubes and rotate and translate them then use difference to remove the parts from the cube. The problem I am having with this method is lining everything up accurately it seems near impossible to line everything up pixel perfect, it also is very difficult to get the slopes to start at the same height on the front and rear.

So I thought of a different way I could make thin cubes of 2mm thick as I wanted walls that thick anyway, such as using x, y, z of [56, 2, 22] and then rotate and translate them, this has the added benefit of not needing to have anything cut out from the inside of the cube to make the walls 2mm thick. It however doesn't solve the problem of lining everything up accurately it still seems near impossible to line everything up pixel perfect.

Once I have been able to resolve the above issues I was wanting to cut a rectangle hole in the front slope, the rear slope won't have a hole cut into it.

If someone could potentially share their thoughts and ideas, or perhaps even give some recommendations as to what you think I should do to get the results I am after it would be very much appreciated, I wouldn't necessarily need the code writing for me as I do have a programming/scripting background, but that being said if you would like to share some rough examples to explain what your suggesting that would be very much appreciated.

Thank you in advanced.

just use hull.

Here's an example ... it's actually slightly different than my description because once you go 2D, you can make things even easier with the offset function.

(The cutting out of the inner empty space is deliberately displaced so that you can see it :-)

How about this?

/

---------------------------------------------------------------------/3D Trapaziod

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

module Trapaziod3D(height, topWidth, topLength, bottomWidth, bottomLength)

{

hull()

{

cube([bottomWidth, bottomLength, .1], center = true);

translate([0,0,height])

{

cube([topWidth, topLength, .1], center = true);

}

}

}

Not sure I understand all the details ...

I would probably try to design the side as a 2D polygon, then linear_extrude it into a box.

Then I'd create the crosssection of the empty space inside as a second 2D polygon, extrude it into a box, and subtract it from the first box.

(I hope I understood the task at hand correctly, if not, I apologize!)

@Bikecyclist The example you made looks good, although the code looks a bit complex, I'm going to need a moment to figure that out for myself, I only found out about OpenSCAD today, someone on thingiverse said they use it for all their models (don't think they are in this group).

I've attached my first and second attempts to my original post, although it's now been flagged for moderation since I have done that.

This "flagging on edit" thing seems to be some kind of bug ... I've had that more than once, too!

If you're interested in the trigonometry, I've tried to explain it with a simple example in this thread: https://www.thingiverse.com/groups/openscad/forums/general/topic:28353

Once you've wrapped your head around it (which I hope with the clockface example will be easy-ish), it often helps to solve those "pixel-positioning" problems pretty quickly.

The basic shape that you want seems to be a kind of a trapezoidal prism. I can think of two simple ways of defining something like this:

1) define two squares and build a hull around them

2) define points and build a polyhedron using them (example: https://github.com/dannystaple/OpenSCAD-Parts-Library/blob/master/prism.scad)

If you make it parametric, there should be no difficulty in creating a difference of the outer shape and another offset inside.

After you have the basic shape done, things like cutting a hole from one side etc are just minor technicalities. I hope this helps.

@svofski Thanks for your reply, I am unsure what you mean by build a hull around them. I have the two squares defined as that was my second idea attempt.

That prism code makes nice triangles, am not sure just how it is doing that however, but looks good I think I may possibly be able to use that.

"hull ()" is an OpenSCAD function. It's powerful, but if applied to 3D objects, it takes a lot of computing time.

Think of it as a rubber balloon stretched tightly over any number of 3D objects, enveloping them closely. That's the kind of shape you can create with "hull ()".

If you box had slopes on all four sides so you couldn't build it as a linear_extrusion of a 2D shape, hull () might be a good choice. It can deal with irregular shapes and is easy to apply, but you can end up with really long computing times ... take your pick.

(It also works on 2D objects, where it's really quick in comparison.)

Another option is to use my pointHull() library module: https://www.thingiverse.com/thing:3696364

Just feed it a list of the coordinates of the corners of the box (or any other convex shape), and it'll put a convex hull around them. No need to figure out the faces for feeding into polyhedron(), no unnecessary bumps from calling hull() with thin 3D slabs, etc.

E.g.,

`pointHull([ [0,0,0], [0,bottomWidth,0], [bottomLength,0,0], [bottomLength,bottomWidth,0], [xOffset,0,height], [xOffset,topWidth,height], [xOffset+topLength,0,height], [xOffset+topLength,topWidth,height] ]);`

I am also having trouble visualizing the box you want. Does it look anything like this?

This is just the outer box, and I have just used randomly chosen coordinates for the slope.

Just a starter.

Similar, but with the slopes on the other faces.

@lar3ry Both are those are what I was after, I'm not sure I understand the difference between the two visually they look similar ish, but split into triangles on the second one.

I would want to 3D print the final result, how would I hollow out the middle? as I would want walls that are 2mm thick. I've attached a screenshot of my first attempt, I did try and add them to my initial post but it has been flagged for moderation since doing so.

Not sure what you mean by "split into triangles on the second one". The two boxes are different in that one has the slopes on the short dimension and the other has them on the long dimension. They are two separate objects.

The next order of business is to hollow out the box, as you say. In general, the way to do that is to make a smaller box, translate it into position, and use difference() to subtract it from the larger box.

In the attached file, there are three modules and the main program.

box_profile() is a 2D object that we can extrude. It is called twice from the module box_shell() to create the desired shape.

box_shell() creates a 3D object that looks like the box without the end walls. If you want to see what that looks like, place a ! in front of the call to box_shell() in the main program. This makes it show the shell only.

end_wall() makes an end wall, which we can rotate/translate into place in order to enclose the box.

The main program creates the hollow box by calling box_shell() once and end_wall() twice, translating the second wall to the far end. This is done within a union() which causes them to be combined wherever they overlap.

It then creates a cube to cut out the bottom of the box (because it looked like you wanted it open in your capture pic), and another cube, rotated and translated to cut out the front opening. Within the difference() statement, the object within the union has the two cubes subtracted from it.

You will notice that there is a # in front of the front opening cube statement. This makes it highlight when previewed (F5). Handy for showing parts in relation to each other. Render (F6) will show the result, with no highlighting.

All you have left to do is to adjust the points in the polygon, the angles of the slopes, and the various dimensions for the cubes.

Pardon the long windedness, but I though you might benefit from knowing the details of it.

@AeroMaxx I find it a bit difficult to express geometries verbally, how about this screenshot instead. Does it look remotely like something you have in mind?

@svofski I did try and add my files to my initial post, but it has been flaggerd for moderation, this seems to be a long process I was hoping it would have been done by now. I've added a screenshot hope this helps!

Your picture is sort of what I was after, but slopes only on two sides, and not at the same angle.

Ok, here is an idea...

The shape consists of a hull between two planes, top side and base. The angles of the side slopes depends on the Y size of the top plane, and to adjust the angles just change TopSideYOffset. The hollowing is made scaling the original box down to a certain size. This will not give you the ability to select an exact wall size, just eyeballing...second thing is the slope wall is sligtly thinner near the bottom...

It may not be your solution, but adds ideas that can be worked on...

If you are going to print it, I will consider not hollowing it out, but making it solid and use a low infill because the top side of your print will need support anyway...

BoxSizeX = 60;

BoxSizeY = 40;

BoxSizeZ = 6;

BoxTopSizeY = 30;

Scale=[0.99,0.95,0.9];

TopSideOffsetY=3;

XSection=1;

YSection=1;

difference ()

{

Box(BoxSizeX,BoxSizeY,BoxSizeZ,BoxTopSizeY,TopSideOffsetY);

}

module Box(BoxSizeX,BoxSizeY,BoxSizeZ,BoxTopSizeY,TopSideOffsetY)

{

hull()

{

translate([0,0,-BoxSizeZ/2])

cube([BoxSizeX,BoxSizeY,0.01],center=true);

translate([0,TopSideOffsetY,BoxSizeZ/2])

cube([BoxSizeX,BoxTopSizeY,0.01],center=true);

}

@AeroMaxx it really helps seeing the draft of what you're trying to get. It differs from what I sketched because there's also a vertical part on one side, which makes that bit also asymmetrical. There are numerous ways of doing that, but in this case I would just follow the intuition and actually start with a cube, then shave off the slopes from it using difference() with 2 other rotated and translated cubes. As if you were making it from a block of wood with a chisel.

The hole is another subtracted cube. You'll just have to figure out the rotations/translations. If you can't simply eyeball them, probably some maths with a sideways 2d projection on a piece of paper would help to figure out the angles and offset.

@svofski "I would just follow the intuition and actually start with a cube, then shave off the slopes from it using difference() with 2 other rotated and translated cubes."

You mentioned the above, in the picture that is exactly what I did.

"The hole is another subtracted cube."

Yes that's what I have done also to get where I currently am, but am unhappy with the results so far. The problem I am having is that the height the slope starts at is different on the front and rear, the slopes don't start at the same z value, and as mentioned it's extremely difficult to line everything up pixel perfect.

You mentioned some maths with a sideways 2d projection on a piece of paper you totally lost me here, I know what angles I would like the slopes to be at, but lining them up is a nightmare it seems.

I would also need to somehow hollow out the whole of the middle as I was intending to 3d print it, and was wanting 2mm thick walls for the inside.

@AeroMaxx if you know the angles of the slopes and where they start, there's no maths involved as such. You just need to put the chiseling cubes in their respective positions. For example:

eps=0.01;

tost(x=40,y=20,h=20,h1=2,h2=4,a1=15,a2=-10);

// width, depth, height, left vertical height, right vertical height

//

module tost(x,y,h,h1,h2,a1,a2)

{

Q=[33,33,33]; // chisel cube, should be le big

}

As for hollowing out, there were other examples in this thread already. The basic idea is to subtract a smaller copy of the same shape from the bigger copy of same. Alternatively, any slicer will do that if you set infill to zero.

With regard to hollowing it out, the "standard" method is to make the solid box a module in OpenSCAD to which you pass the size as a parameter, like "module solidbox (x, y, z)".

Then the main code looks like this:

wall = 2;

difference

{

solidbox (x, y, z);

solidbox (x - 2 * wall, y - 2 * wall, z - 2 * wall);

}

(You might need a "translate" before the second solidbox if you're not creating the solidbox centered on the origin, as I assumed.)