Hi all
I am designing a pair of earrings based on a Mobius band, with text
subtracted from its flat surface.
One example of an OpenSCAD script to generate a Mobius band is here:
http://kitwallace.tumblr.com/post/75264490978/mobius-strip
I'm struggling slightly to wrap text around this geometry. The best I
can come up with so far is to subtract the text from a simple cuboid,
then chop it into many slices and twist them from -90 to +90 degrees
along the length, then bend the whole thing around a circle (or even
ellipse).
Has anyone a neat trick to do this in an efficient manner which can
generate a nice high resolution output?
The result will be printed by Shapeways at high resolution in stainless
steel and polished, for an 11th wedding anniversary present...
Cheers
Alex
The usual technique is to chop the text in small pieces and to position them
accordingly over the target surface. As the Moebius strip is a ruled surface
and the model you referred is made of slightly twisted and tapered thin
blocks, I used them to chop the text.
http://forum.openscad.org/file/n18156/Moebius_text.png
Moebius_strip_text.scad
http://forum.openscad.org/file/n18156/Moebius_strip_text.scad
The above image has been rendered in 4 min with a step size of 5 degrees. A
finer 1 degree model required 32 min to render.
Hope it helps.
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18156.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I recently did an OpenSCAD program to wrap an image around a conic surface,
and also to do it for any surface which can be defined by Z=f (X,Y). If you
render your text to a PNG file, you might be able to apply this? But I
don't know enough maths to know whether that would work for a complex
geometry like a moebius strip (I suspect not). Thingiverse 1668883
On 18/08/2016 17:38, "Ronaldo" rcmpersiano@gmail.com wrote:
The usual technique is to chop the text in small pieces and to position
them
accordingly over the target surface. As the Moebius strip is a ruled
surface
and the model you referred is made of slightly twisted and tapered thin
blocks, I used them to chop the text.
http://forum.openscad.org/file/n18156/Moebius_text.png
Moebius_strip_text.scad
http://forum.openscad.org/file/n18156/Moebius_strip_text.scad
The above image has been rendered in 4 min with a step size of 5 degrees. A
finer 1 degree model required 32 min to render.
Hope it helps.
--
View this message in context: http://forum.openscad.org/
Wrapping-text-around-a-complex-geometry-tp18145p18156.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thanks, this is the method I had in mind but it's great to confirm and you've given me a great leg up!
Cheers
Alex
Tapped on my mobile phone.
On 18 Aug 2016, at 07:37, Ronaldo rcmpersiano@gmail.com wrote:
The usual technique is to chop the text in small pieces and to position them
accordingly over the target surface. As the Moebius strip is a ruled surface
and the model you referred is made of slightly twisted and tapered thin
blocks, I used them to chop the text.
http://forum.openscad.org/file/n18156/Moebius_text.png
Moebius_strip_text.scad
http://forum.openscad.org/file/n18156/Moebius_strip_text.scad
The above image has been rendered in 4 min with a step size of 5 degrees. A
finer 1 degree model required 32 min to render.
Hope it helps.
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18156.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Another way of approaching this type of problem is set out below. I have used
this in the past and IMO it is theoretically more elegant, however its
implementation in OpenSCAD is far less so...
Taking a simple example of a cube:
cube(10);
Render and export as an Additive Manufacturing File (AMF).
Load the AMF file into a text editor and reformat the xml vertex and
triangle data into a OpenSCAD script format. This is most easily done using
a find & replace macro, an example of a VB macro for Word is included at the
end (this is definitely not elegant but got the job done :) ).
Paste the result into OpenSCAD:
points=[[0,0,10],[0,10,10],[0,0,0],[0,10,0],[10,0,10],[10,10,10],[10,0,0],[10,10,0]];
triangles=[[0,1,2],[2,1,3],[0,4,5],[1,0,5],[2,6,4],[0,2,4],[3,7,2],[2,7,6],[1,5,3],[3,5,7],[6,7,5],[4,6,5]];
polyhedron(points,triangles);
It produces the same cube, but you now have access to the raw vertex data.
Now using text as an example:
linear_extrude(height=1) text("Hello world!");
Again render and export as an AMF file. Then load and reformat the AMF file
in a text editor, before pasting back into the OpenSCAD editor:
points=[[64.7295,0.582993,0],[64.9412,0.860992,0],...[46.3348,3.687,1]];
triangles=[[0,1,2],[3,0,2],...[632,633,693]];
polyhedron(points,triangles);
This produces the same text object.
However the vertex data can be re-mapped (non-affine transformation), for
example:
points2=[ for(i=points) [i[0],i[1]+5sin(8i[0]),4*i[2]] ];
polyhedron(points2,triangles);
http://forum.openscad.org/file/n18163/HelloWorld2.png
Using a suitable mapping the text can be wrapped around a surface:
r1=20;
points3=[ for(i=points) let(a=1.7i[0],r=r1+2i[2]-1)
[-rcos(a),i[1],rsin(a)] ];
difference(){
rotate([90,0,0]) cylinder(r=r1,h=25,center=true,$fn=60);
polyhedron(points3,triangles,convexity=10);
}
http://forum.openscad.org/file/n18163/HelloWorld3.png
Cheers,
Trygon
' VB Microsoft Word macro
Sub AMFtoOpenSCAD()
Dim CRLF As String
CRLF = Chr(13) + Chr(10)
ReplaceText " ", ""
ReplaceText "<mesh>", CRLF
ReplaceText "</mesh>", CRLF + "polyhedron(points,triangles);" + CRLF
ReplaceText "<vertices>", CRLF + "points=["
ReplaceText "</vertices>", "];" + CRLF
ReplaceText "</vertex><vertex>", ","
ReplaceText "<vertex>", ""
ReplaceText "</vertex>", ""
ReplaceText "<coordinates>", "["
ReplaceText "</coordinates>", "]"
ReplaceText "<x>", ""
ReplaceText "</x>", ","
ReplaceText "<y>", ""
ReplaceText "</y>", ","
ReplaceText "<z>", ""
ReplaceText "</z>", ""
ReplaceText "<volume>", CRLF + "triangles=["
ReplaceText "</volume>", "];" + CRLF
ReplaceText "</triangle><triangle>", "],["
ReplaceText "<triangle>", "["
ReplaceText "</triangle>", "]"
ReplaceText "<v1>", ""
ReplaceText "</v1>", ","
ReplaceText "<v2>", ""
ReplaceText "</v2>", ","
ReplaceText "<v3>", ""
ReplaceText "</v3>", ""
End Sub
Sub ReplaceText(text1 As String, text2 As String)
With Selection.Find
.Text = text1
.Replacement.Text = text2
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
-ends-
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18163.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Trygon,
I've trying such technique but with a different combination: STL -
Notepad++ using macros with regular expression finds. It is a very general
technique but it is far from elegant. Elegant would be to have a function
or module in OpenSCAD to retrieve the polyhedron data of any solid.
Something like:
data = polyhedron_data() cube();
where data would be of the form: [ <vertex list>, <facet list> ].
This would require that modules returned values (as functions do) or
functions accepted solids as parameters (as module do in some sense).
May be in OpenSCAD2...
2016-08-18 18:26 GMT-03:00 Trygon db5765@outlook.com:
Another way of approaching this type of problem is set out below. I have
used
this in the past and IMO it is theoretically more elegant, however its
implementation in OpenSCAD is far less so...
Taking a simple example of a cube:
cube(10);
Render and export as an Additive Manufacturing File (AMF).
Load the AMF file into a text editor and reformat the xml vertex and
triangle data into a OpenSCAD script format. This is most easily done using
a find & replace macro, an example of a VB macro for Word is included at
the
end (this is definitely not elegant but got the job done :) ).
Paste the result into OpenSCAD:
points=[[0,0,10],[0,10,10],[0,0,0],[0,10,0],[10,0,10],[10,
10,10],[10,0,0],[10,10,0]];
triangles=[[0,1,2],[2,1,3],[0,4,5],[1,0,5],[2,6,4],[0,2,4],[
3,7,2],[2,7,6],[1,5,3],[3,5,7],[6,7,5],[4,6,5]];
polyhedron(points,triangles);
It produces the same cube, but you now have access to the raw vertex data.
Now using text as an example:
linear_extrude(height=1) text("Hello world!");
Again render and export as an AMF file. Then load and reformat the AMF file
in a text editor, before pasting back into the OpenSCAD editor:
points=[[64.7295,0.582993,0],[64.9412,0.860992,0],...[46.3348,3.687,1]];
triangles=[[0,1,2],[3,0,2],...[632,633,693]];
polyhedron(points,triangles);
This produces the same text object.
However the vertex data can be re-mapped (non-affine transformation), for
example:
points2=[ for(i=points) [i[0],i[1]+5sin(8i[0]),4*i[2]] ];
polyhedron(points2,triangles);
http://forum.openscad.org/file/n18163/HelloWorld2.png
Using a suitable mapping the text can be wrapped around a surface:
r1=20;
points3=[ for(i=points) let(a=1.7i[0],r=r1+2i[2]-1)
[-rcos(a),i[1],rsin(a)] ];
difference(){
rotate([90,0,0]) cylinder(r=r1,h=25,center=true,$fn=60);
polyhedron(points3,triangles,convexity=10);
}
http://forum.openscad.org/file/n18163/HelloWorld3.png
Cheers,
Trygon
' VB Microsoft Word macro
Sub AMFtoOpenSCAD()
Dim CRLF As String
CRLF = Chr(13) + Chr(10)
ReplaceText " ", ""
ReplaceText "<mesh>", CRLF
ReplaceText "</mesh>", CRLF + "polyhedron(points,triangles);" + CRLF
ReplaceText "<vertices>", CRLF + "points=["
ReplaceText "</vertices>", "];" + CRLF
ReplaceText "</vertex><vertex>", ","
ReplaceText "<vertex>", ""
ReplaceText "</vertex>", ""
ReplaceText "<coordinates>", "["
ReplaceText "</coordinates>", "]"
ReplaceText "<x>", ""
ReplaceText "</x>", ","
ReplaceText "<y>", ""
ReplaceText "</y>", ","
ReplaceText "<z>", ""
ReplaceText "</z>", ""
ReplaceText "<volume>", CRLF + "triangles=["
ReplaceText "</volume>", "];" + CRLF
ReplaceText "</triangle><triangle>", "],["
ReplaceText "<triangle>", "["
ReplaceText "</triangle>", "]"
ReplaceText "<v1>", ""
ReplaceText "</v1>", ","
ReplaceText "<v2>", ""
ReplaceText "</v2>", ","
ReplaceText "<v3>", ""
ReplaceText "</v3>", ""
End Sub
Sub ReplaceText(text1 As String, text2 As String)
With Selection.Find
.Text = text1
.Replacement.Text = text2
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
-ends-
--
View this message in context: http://forum.openscad.org/
Wrapping-text-around-a-complex-geometry-tp18145p18163.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I've added a python program to convert AMF files into polyhedron scad format
files.
Check it out here:
Any testing would be great. I've tried to make it so you can just drop an
AMF file onto the python program but that will only work if you have it
setup in your OS (Win or Mac) correctly - don't ask me how.
For everyone else, the first couple of lines has the filename of the AMF
file like so:
filename = "test.amf"
just edit that and run it.
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18169.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Just tried with the test files on AMF site:
worked well. Some are compressed - rename as zip and you can uncompress then
to ascii and then run then through.
Banana for scale :)
http://forum.openscad.org/file/n18172/3_bananas_convert_-_OpenSCAD_3.png
Banana file is 63MB uncompressed.
Drillparts.amf is 85MB uncompressed and has 35 meshes. All correctly(?)
extracted to 9.8MB SCAD file.
Scintilla does its best to allow you to edit it but frankly YMMV.
http://forum.openscad.org/file/n18172/drillparts_convert_-_OpenSCAD_4.png
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18172.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Very interesting! I will try that.
Tapped on my mobile phone.
On 18 Aug 2016, at 23:26, Trygon db5765@outlook.com wrote:
Another way of approaching this type of problem is set out below. I have used
this in the past and IMO it is theoretically more elegant, however its
implementation in OpenSCAD is far less so...
Taking a simple example of a cube:
cube(10);
Render and export as an Additive Manufacturing File (AMF).
Load the AMF file into a text editor and reformat the xml vertex and
triangle data into a OpenSCAD script format. This is most easily done using
a find & replace macro, an example of a VB macro for Word is included at the
end (this is definitely not elegant but got the job done :) ).
Paste the result into OpenSCAD:
points=[[0,0,10],[0,10,10],[0,0,0],[0,10,0],[10,0,10],[10,10,10],[10,0,0],[10,10,0]];
triangles=[[0,1,2],[2,1,3],[0,4,5],[1,0,5],[2,6,4],[0,2,4],[3,7,2],[2,7,6],[1,5,3],[3,5,7],[6,7,5],[4,6,5]];
polyhedron(points,triangles);
It produces the same cube, but you now have access to the raw vertex data.
Now using text as an example:
linear_extrude(height=1) text("Hello world!");
Again render and export as an AMF file. Then load and reformat the AMF file
in a text editor, before pasting back into the OpenSCAD editor:
points=[[64.7295,0.582993,0],[64.9412,0.860992,0],...[46.3348,3.687,1]];
triangles=[[0,1,2],[3,0,2],...[632,633,693]];
polyhedron(points,triangles);
This produces the same text object.
However the vertex data can be re-mapped (non-affine transformation), for
example:
points2=[ for(i=points) [i[0],i[1]+5sin(8i[0]),4*i[2]] ];
polyhedron(points2,triangles);
http://forum.openscad.org/file/n18163/HelloWorld2.png
Using a suitable mapping the text can be wrapped around a surface:
r1=20;
points3=[ for(i=points) let(a=1.7i[0],r=r1+2i[2]-1)
[-rcos(a),i[1],rsin(a)] ];
difference(){
rotate([90,0,0]) cylinder(r=r1,h=25,center=true,$fn=60);
polyhedron(points3,triangles,convexity=10);
}
http://forum.openscad.org/file/n18163/HelloWorld3.png
Cheers,
Trygon
' VB Microsoft Word macro
Sub AMFtoOpenSCAD()
Dim CRLF As String
CRLF = Chr(13) + Chr(10)
ReplaceText " ", ""
ReplaceText "<mesh>", CRLF
ReplaceText "</mesh>", CRLF + "polyhedron(points,triangles);" + CRLF
ReplaceText "<vertices>", CRLF + "points=["
ReplaceText "</vertices>", "];" + CRLF
ReplaceText "</vertex><vertex>", ","
ReplaceText "<vertex>", ""
ReplaceText "</vertex>", ""
ReplaceText "<coordinates>", "["
ReplaceText "</coordinates>", "]"
ReplaceText "<x>", ""
ReplaceText "</x>", ","
ReplaceText "<y>", ""
ReplaceText "</y>", ","
ReplaceText "<z>", ""
ReplaceText "</z>", ""
ReplaceText "<volume>", CRLF + "triangles=["
ReplaceText "</volume>", "];" + CRLF
ReplaceText "</triangle><triangle>", "],["
ReplaceText "<triangle>", "["
ReplaceText "</triangle>", "]"
ReplaceText "<v1>", ""
ReplaceText "</v1>", ","
ReplaceText "<v2>", ""
ReplaceText "</v2>", ","
ReplaceText "<v3>", ""
ReplaceText "</v3>", ""
End Sub
Sub ReplaceText(text1 As String, text2 As String)
With Selection.Find
.Text = text1
.Replacement.Text = text2
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
-ends-
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18163.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Hey Ronaldo
No intention of causing offence, I think your approach is just fine. Perhaps
instead of "elegant" I should have said "intuitive" ;-)
-Trygon
--
View this message in context: http://forum.openscad.org/Wrapping-text-around-a-complex-geometry-tp18145p18179.html
Sent from the OpenSCAD mailing list archive at Nabble.com.