# Wrapping text around a complex geometry

8 messages
Open this post in threaded view
|

## Wrapping text around a complex geometry

 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-stripI'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 _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Wrapping text around a complex geometry

 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. Moebius_strip_text.scadThe 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.
Open this post in threaded view
|

## Re: Wrapping text around a complex geometry

 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" <[hidden email]> 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. 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Wrapping text around a complex geometry

 In reply to this post by Ronaldo 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 <[hidden email]> 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. > > > 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 > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: Wrapping text around a complex geometry

 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]+5*sin(8*i[0]),4*i[2]] ];   polyhedron(points2,triangles); Using a suitable mapping the text can be wrapped around a surface: r1=20; points3=[ for(i=points) let(a=1.7*i[0],r=r1+2*i[2]-1) [-r*cos(a),i[1],r*sin(a)] ]; difference(){     rotate([90,0,0]) cylinder(r=r1,h=25,center=true,\$fn=60);     polyhedron(points3,triangles,convexity=10); } Cheers, Trygon --------------- ' VB Microsoft Word macro Sub AMFtoOpenSCAD()     Dim CRLF As String     CRLF = Chr(13) + Chr(10)     ReplaceText " ", ""         ReplaceText "", CRLF     ReplaceText "", CRLF + "polyhedron(points,triangles);" + CRLF         ReplaceText "", CRLF + "points=["     ReplaceText "", "];" + CRLF     ReplaceText "", ","     ReplaceText "", ""     ReplaceText "", ""     ReplaceText "", "["     ReplaceText "", "]"     ReplaceText "", ""     ReplaceText "", ","     ReplaceText "", ""     ReplaceText "", ","     ReplaceText "", ""     ReplaceText "", ""         ReplaceText "", CRLF + "triangles=["     ReplaceText "", "];" + CRLF     ReplaceText "", "],["     ReplaceText "", "["     ReplaceText "", "]"     ReplaceText "", ""     ReplaceText "", ","     ReplaceText "", ""     ReplaceText "", ","     ReplaceText "", ""     ReplaceText "", "" 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-
Open this post in threaded view
|