As a newcomer to openSCAD I was delighted to see there was a means to
import and STL file and managed to do so successfully.
Then as I basked in my glory, reality reared it's ugly head, once again,
and I realized I had no idea how to proceed to manipulate the image I
could now see.
A quick look through the wikibook did not provide a clue. Where might I
look to benefit from those who know?
On 3/31/2022 9:56 AM, joe a wrote:
As a newcomer to openSCAD I was delighted to see there was a means to
import and STL file and managed to do so successfully.
Then as I basked in my glory, reality reared it's ugly head, once
again, and I realized I had no idea how to proceed to manipulate the
image I could now see.
A quick look through the wikibook did not provide a clue. Where might
I look to benefit from those who know?
What is important to understand about STL import is that the result of
an import is an object just like the result of any other OpenSCAD
operations.
You can take that object and modify it as you can modify any other
object. You can rotate, scale, translate, and skew it. You can union,
intersect, and difference it. You can do more advanced things like hull
and Minkowski sum on it.
What you cannot do is look inside it. You can't get a list of
vertices or faces, or anything like that - just as when you create a
cube with cube() there is no way to peek inside it. OpenSCAD is not a
mesh editor; you cannot directly manipulate faces and vertices.
So, suppose that you had an STL that fit into a 100x100x100 cube in the
+XYZ octant, and you wanted only the top half of it. You could do
something like this:
difference() {
translate([-50,-50,-50])
import("myobject.stl");
translate([0,0,-100])
cube(200, center=true);
}
Here's a more elaborate program that I wrote to turn a 3D scan of my
head into a Lego minifig head:
$fa = 0.1;
$fs = 0.3;
module jordanhead() {
scale(1/264) { // Scale to unit diameter
intersection() {
translate([30,-3,80]) import("Jordan head.stl", convexity=10);
cylinder(d=264, h=250);
}
}
}
%scale(0.25) translate([113,58,-131])
import("Blank_Minifig_Jumbo_Snap_Together_Version/Blank_Head.stl");
difference() {
union() {
translate([-0.5,0,0]) scale(1.1) scale(10.2) jordanhead();
translate([0,0,9]) cylinder(d=5, h=1.78+1.5);
cylinder(d=6.2, h=5);
}
translate([0,0,-1]) cylinder(d=5.1, h=7+1);
}
Parts of this program - the dimensions of the Lego stud and
corresponding hole - should be better parameterized. Other parts - how
those pieces relate to the STL - must necessarily be magic constants.
Enclosed please find the scan of my head. Alas, the blank Minifig head
(used only for size comparison) is not mine and does not seem to be on
Thingiverse any more so I don't feel free to distribute it.
On 3/31/2022 1:48 PM, Jordan Brown wrote:
On 3/31/2022 9:56 AM, joe a wrote:
As a newcomer to openSCAD I was delighted to see there was a means to
import and STL file and managed to do so successfully.
Then as I basked in my glory, reality reared it's ugly head, once
again, and I realized I had no idea how to proceed to manipulate the
image I could now see.
A quick look through the wikibook did not provide a clue. Where might
I look to benefit from those who know?
What is important to understand about STL import is that the result of
an import is an object just like the result of any other OpenSCAD
operations.
You can take that object and modify it as you can modify any other
object. You can rotate, scale, translate, and skew it. You can union,
intersect, and difference it. You can do more advanced things like hull
and Minkowski sum on it.
What you cannot do is look inside it. You can't get a list of
vertices or faces, or anything like that - just as when you create a
cube with cube() there is no way to peek inside it. OpenSCAD is not a
mesh editor; you cannot directly manipulate faces and vertices.
So, suppose that you had an STL that fit into a 100x100x100 cube in the
+XYZ octant, and you wanted only the top half of it. You could do
something like this:
difference() {
translate([-50,-50,-50])
import("myobject.stl");
translate([0,0,-100])
cube(200, center=true);
}
Here's a more elaborate program that I wrote to turn a 3D scan of my
head into a Lego minifig head:
$fa = 0.1;
$fs = 0.3;
module jordanhead() {
scale(1/264) { // Scale to unit diameter
intersection() {
translate([30,-3,80]) import("Jordan head.stl", convexity=10);
cylinder(d=264, h=250);
}
}
}
%scale(0.25) translate([113,58,-131])
import("Blank_Minifig_Jumbo_Snap_Together_Version/Blank_Head.stl");
difference() {
union() {
translate([-0.5,0,0]) scale(1.1) scale(10.2) jordanhead();
translate([0,0,9]) cylinder(d=5, h=1.78+1.5);
cylinder(d=6.2, h=5);
}
translate([0,0,-1]) cylinder(d=5.1, h=7+1);
}
Parts of this program - the dimensions of the Lego stud and
corresponding hole - should be better parameterized. Other parts - how
those pieces relate to the STL - must necessarily be magic constants.
Enclosed please find the scan of my head. Alas, the blank Minifig head
(used only for size comparison) is not mine and does not seem to be on
Thingiverse any more so I don't feel free to distribute it.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I'll have to experiment. That's for the clues.