new to OpenSCAD, working with projection

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

new to OpenSCAD, working with projection

fred_dot_u
I'm not a CAD person, but have played around with the basics of many different programs.
I'm not a programmer, but have played around with simple stuff over the years, Fortran in college, BASIC later with early home computers and more recently Arduino.

Now that I've discovered OpenSCAD, I've found it is great fun simply to experiment with various features. I've been reading the forum/mailing list posts, trying to understand it, but much of the programming is beyond me. My method of learning is to try something, even if it does not work, then try something to make it work. To that end, my current experiment is using projection().

Please excuse the simplistic nature of my current work. On the positive side, it's only a few lines at a time.

color("white") 
import("concreteblockA.stl");
basic concrete block in white




The above image was a conversion from .dxf to .stl and using meshmixer to export as ASCII .stl to keep OpenSCAD happy. White was selected to enable me to see what I hoped would be differences in image as the experimentation progressed.

projection(cut=true)
color("white") 
import("C:/Users/Fred/Downloads/concreteblockA.stl");

concrete block sliced

So far, this is what I expected to discover. One part of the experiment involves horizontal slices that move upward through the model, but doing so to this model would result in identical images, so that was out as an experimental step. I felt it would be wise to rotate the block and slice it to accomplish the next step.

rotate([90,0,0]) translate([0,-50,0])
color("white") 
import("concreteblockA.stl");

concrete block rotated

So far so good. I then expected that the projection() would result in a rectangle on the xy plane with no cut-outs, simply a shadow of the block. The result of the F6 key was identical to the projection image posted above. The result of the F5 key was the same outline, rotated into the xz plane, not what I expected.

concrete block rotated and sliced F5

I've found a few examples of using projection in the forum archive, but it's so deeply embedded in programming loops that I'm unable to ferret out what I'm doing wrong. If I can get it correctly written, I'd expect to be able to slice the block (at the last pictured orientation) at any location. At the very bottom or very top, the slice would be a rectangle. In other locations, I'd expect the slice to be three narrow rectangles spaced appropriately based on the internal structure of the block.

For this particular experiment, I could have rotated the block in the CAD program, prior to exporting it to .stl and probably achieved the result noted above, but that would not be an option for future models processed in this manner.

Can someone tell me where I'm going wrong? Am I missing something simple?

thanks
fred
Reply | Threaded
Open this post in threaded view
|

Re: new to OpenSCAD, working with projection

Bananapeel
The f5 preview gives wrong results sometimes. The f6 is the real result.

You can't rotate 2d parts around any other axis than the Z axis, or translate them other than the X and Y axis. Ensure you don't do that.

Reply | Threaded
Open this post in threaded view
|

Re: new to OpenSCAD, working with projection

fred_dot_u
Thanks for the reply. If F6 provides the real result, which was the same image for both orientations of the block, it does not appear to be working.

I'm rotating the block to make the holes pass horizontally, not vertically, which is 3D:
rotate([90,0,0]) translate([0,-50,0])
color("white") 
import("concreteblockA.stl");

yet the projection portion using F6 appears to slice out the non-rotated block.

Originally the code read thusly:

rotate([90,0,0]) translate([0,-32,0])
projection(cut=true)
color("white") 
import("C:/Users/Fred/Downloads/concreteblockA.stl");

and the result was the same as the non-rotate part.

Just for experimentation sake, I moved the commands a bit:

projection(cut=true)
rotate([90,0,0]) translate([0,-32,0])
color("white") 
import("C:/Users/Fred/Downloads/concreteblockA.stl");

block sliced and rotated

As shown in the image, it's "picking up" the webs of the block as I had wanted and expected. Swapping the two lines created the solution.

Although F5 may not always provide correct results, when used with this code, it works as well.

You suggest that I can't rotate 2D parts around anything other than the Z axis, which is easy to understand, as well as your translate comments. Is a 2D part of zero thickness? I understood the slices to be 1 mm thick, making them 3d, generally speaking.

That's going to have to sit in my reserve memory and become an experiment for later days.

Problem solved! thanks again.
Reply | Threaded
Open this post in threaded view
|

Re: new to OpenSCAD, working with projection

QuackingPlums
Whether a 2D part has thickness would not affect the outcome in your example – it is the order of operation that is important.
Slicing a rotated object is different from rotating a sliced one, which is what you discovered by swapping the two lines.
Reply | Threaded
Open this post in threaded view
|

Re: new to OpenSCAD, working with projection

nophead
2D parts have no thickness although the preview displays them as 1mm thick 3D parts. To give it a thickness and convert it back to a 3D part use linear_extrude().

On 6 November 2014 15:15, QuackingPlums <[hidden email]> wrote:
Whether a 2D part has thickness would not affect the outcome in your example
– it is the order of operation that is important.
Slicing a rotated object is different from rotating a sliced one, which is
what you discovered by swapping the two lines.




--
View this message in context: http://forum.openscad.org/new-to-OpenSCAD-working-with-projection-tp10099p10102.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566