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.
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.
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.
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.
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?
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.
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.
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.