discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] How to write a texture to a face(Solid ) in a geometric model

P
Parkinbot
Sat, Mar 26, 2016 5:48 PM

As Michael wrote, OpenSCAD has no support for pinning a texture to a solid.
Also any color information gets lost when CGAL rendering (F6) is done for
STL export.

But if you have a dual or multiple head printer and a slicer that can handle
multiple STLs, one for each filament color, you can use OpenSCAD to produce
distinct STLs, one for each color and get a colored print.
Here some code that carves colored text (or any other texture) like a tarsia
into a solid. (Text is projected):

http://forum.openscad.org/file/n16734/texture.png

// mode = "shape"; // uncomment to view/export shape only
// mode = "text";  // uncomment to view/export text only

textonshape(mode = mode, textcolor = "red")
{
// here is your shape
cylinder(r=10.01, 71, center = true);

// here is your texture, must intersect with your shape
translate([3,6,30]) // to move to the position where you want text
rotate([0,90,90]) // to align with the face of the stl
linear_extrude(height=6, convexity=9)
text("your text");
}

module textonshape(mode = "view", textcolor = "green")
{
if(mode != "shape")
color(textcolor)
intersection() // just the text
{
scale([.999, .999, .999]) children([0]); children([1]);
}
if(mode != "text")
difference()  // just the shape
{
children([0]); children([1]);
}
}

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16734.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

As Michael wrote, OpenSCAD has no support for pinning a texture to a solid. Also any color information gets lost when CGAL rendering (F6) is done for STL export. But if you have a dual or multiple head printer and a slicer that can handle multiple STLs, one for each filament color, you can use OpenSCAD to produce distinct STLs, one for each color and get a colored print. Here some code that carves colored text (or any other texture) like a tarsia into a solid. (Text is projected): <http://forum.openscad.org/file/n16734/texture.png> // mode = "shape"; // uncomment to view/export shape only // mode = "text"; // uncomment to view/export text only textonshape(mode = mode, textcolor = "red") { // here is your shape cylinder(r=10.01, 71, center = true); // here is your texture, must intersect with your shape translate([3,6,30]) // to move to the position where you want text rotate([0,90,90]) // to align with the face of the stl linear_extrude(height=6, convexity=9) text("your text"); } module textonshape(mode = "view", textcolor = "green") { if(mode != "shape") color(textcolor) intersection() // just the text { scale([.999, .999, .999]) children([0]); children([1]); } if(mode != "text") difference() // just the shape { children([0]); children([1]); } } -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16734.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NR
Nageswara rao
Sun, Mar 27, 2016 2:16 AM

Yeah it's working.Is it possible to wrap text taken from .dxf file.I have
attached a sample dxf sketch.

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16743.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Yeah it's working.Is it possible to wrap text taken from .dxf file.I have attached a sample dxf sketch. -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16743.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NR
Nageswara rao
Sun, Mar 27, 2016 5:38 AM

But for Chinese text it is not translating properly.please find attached
picture . http://forum.openscad.org/file/n16744/ch.png

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16744.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

But for Chinese text it is not translating properly.please find attached picture . <http://forum.openscad.org/file/n16744/ch.png> -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16744.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Sun, Mar 27, 2016 6:13 AM

A second approach is to import the DXF into Inkscape and use the openscad
export plugin to export as an object.

Then intersect() and difference() it with cylinder (maybe 6 sides) to get
the wrapped text.

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16745.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

A second approach is to import the DXF into Inkscape and use the openscad export plugin to export as an object. Then intersect() and difference() it with cylinder (maybe 6 sides) to get the wrapped text. - http://www.thingiverse.com/thing:1065500 -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16745.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NR
Nageswara rao
Sun, Mar 27, 2016 7:08 AM

Hello! Cant we do it with out importing into third party software. I would
like to add above functionality locally to OpenScad.Can you please provide
me in details.Thank you.

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16746.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello! Cant we do it with out importing into third party software. I would like to add above functionality locally to OpenScad.Can you please provide me in details.Thank you. -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16746.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NR
Nageswara rao
Sun, Mar 27, 2016 7:15 AM

In above approach
1.export as STL
2. import into OpenScad

results: Text disappears

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16747.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

In above approach 1.export as STL 2. import into OpenScad results: Text disappears -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16747.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Sun, Mar 27, 2016 9:06 AM

Does it appear at all - in mode "text"? Maybe your exporter is not working
properly. Why don't you post the relevant parts of your code?

--
View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16748.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Does it appear at all - in mode "text"? Maybe your exporter is not working properly. Why don't you post the relevant parts of your code? -- View this message in context: http://forum.openscad.org/How-to-write-a-texture-to-a-face-Solid-in-a-geometric-model-tp16718p16748.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Sun, Mar 27, 2016 11:11 AM

On 03/27/2016 09:15 AM, Nageswara rao wrote:

In above approach
1.export as STL
2. import into OpenScad

results: Text disappears

Just using text("something") produces a 2D object, to combine
it with a STL you need to make it 3D, using linear_extrude().
Could that be the problem?

ciao,
Torsten.

On 03/27/2016 09:15 AM, Nageswara rao wrote: > In above approach > 1.export as STL > 2. import into OpenScad > > results: Text disappears > Just using text("something") produces a 2D object, to combine it with a STL you need to make it 3D, using linear_extrude(). Could that be the problem? ciao, Torsten.
TP
Torsten Paul
Sun, Mar 27, 2016 11:50 AM

On 03/27/2016 07:38 AM, Nageswara rao wrote:

But for Chinese text it is not translating properly.please find
attached picture. http://forum.openscad.org/file/n16744/ch.png

text() should be able to handle that, but it needs the
matching font. It will not try to automatically substitute
glyphs from other fonts if one is missing in the selected
font like most text editors do.

For example the following will do Braille

cube([65,12,.5]);
linear_extrude(1)
text("\u2820\u2813\u2811\u2807\u2807\u2815", font="DejaVu Sans");

but that only works with a small number of fonts that have
the actual glyphs (on Linux "DejaVu Sans", on Windows that
could be "Segoe UI Symbol").

If you find it's still not working, please report an issue
on github. We'd need some help from people how know the
languages and have the appropriate fonts installed.

ciao,
Torsten.

On 03/27/2016 07:38 AM, Nageswara rao wrote: > But for Chinese text it is not translating properly.please find > attached picture. <http://forum.openscad.org/file/n16744/ch.png> > text() should be able to handle that, but it needs the matching font. It will not try to automatically substitute glyphs from other fonts if one is missing in the selected font like most text editors do. For example the following will do Braille cube([65,12,.5]); linear_extrude(1) text("\u2820\u2813\u2811\u2807\u2807\u2815", font="DejaVu Sans"); but that only works with a small number of fonts that have the actual glyphs (on Linux "DejaVu Sans", on Windows that could be "Segoe UI Symbol"). If you find it's still not working, please report an issue on github. We'd need some help from people how know the languages and have the appropriate fonts installed. ciao, Torsten.
MS
Mark Schafer
Sun, Mar 27, 2016 11:50 AM

the reason the text() is not working is the particular font selected
does not have those Kanji characters in it.
This means your choice of font is limited. Which is why I suggested
using Inkscape - where you can employ any system font.
Best wishes.

On 3/28/2016 12:11 AM, Torsten Paul wrote:

On 03/27/2016 09:15 AM, Nageswara rao wrote:

In above approach
1.export as STL
2. import into OpenScad

results: Text disappears

Just using text("something") produces a 2D object, to combine
it with a STL you need to make it 3D, using linear_extrude().
Could that be the problem?

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

the reason the text() is not working is the particular font selected does not have those Kanji characters in it. This means your choice of font is limited. Which is why I suggested using Inkscape - where you can employ any system font. Best wishes. On 3/28/2016 12:11 AM, Torsten Paul wrote: > On 03/27/2016 09:15 AM, Nageswara rao wrote: >> In above approach >> 1.export as STL >> 2. import into OpenScad >> >> results: Text disappears >> > Just using text("something") produces a 2D object, to combine > it with a STL you need to make it 3D, using linear_extrude(). > Could that be the problem? > > ciao, > Torsten. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >